From 9bec8918789cb45cc926a5ad24446506aca4fad0 Mon Sep 17 00:00:00 2001 From: Alexander Fedra Date: Mon, 4 May 2015 21:41:08 +0200 Subject: [PATCH 1/2] Use default stream data handler --- src/SecureStream.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/SecureStream.php b/src/SecureStream.php index ce6e1da..df183df 100644 --- a/src/SecureStream.php +++ b/src/SecureStream.php @@ -41,17 +41,6 @@ public function __construct(Stream $stream, LoopInterface $loop) { $this->resume(); } - public function handleData($stream) - { - $data = stream_get_contents($stream); - - $this->emit('data', [$data, $this]); - - if (!is_resource($stream) || feof($stream)) { - $this->end(); - } - } - public function pause() { $this->loop->removeReadStream($this->decorating->stream); From 7b2a45c2bbc9ddc205107346dd35215bbc4f39cd Mon Sep 17 00:00:00 2001 From: Alexander Fedra Date: Tue, 5 May 2015 16:10:58 +0200 Subject: [PATCH 2/2] SSL EOF blocking workaround --- src/SecureStream.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SecureStream.php b/src/SecureStream.php index df183df..b3ba2b1 100644 --- a/src/SecureStream.php +++ b/src/SecureStream.php @@ -41,6 +41,18 @@ public function __construct(Stream $stream, LoopInterface $loop) { $this->resume(); } + public function handleData($stream) + { + $data = fread($stream, $this->bufferSize); + $meta = stream_get_meta_data($stream); + + $this->emit('data', [$data, $this]); + + if (!is_resource($stream) || $meta['eof']) { + $this->end(); + } + } + public function pause() { $this->loop->removeReadStream($this->decorating->stream);