1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-30 04:19:23 +01:00

Fix Message::read() when end is reached before call to read()

This commit is contained in:
Bob Weinand 2017-05-11 16:33:00 +02:00 committed by GitHub
parent 11a92648d1
commit 98bbffb48f

View File

@ -88,10 +88,6 @@ class Message implements InputStream, Promise {
return new Failure(new PendingReadException);
}
if ($this->closed) {
return new Success;
}
if ($this->buffer !== "") {
$buffer = $this->buffer;
$this->buffer = "";
@ -104,6 +100,10 @@ class Message implements InputStream, Promise {
return new Success($buffer);
}
if ($this->closed) {
return new Success;
}
$this->pendingRead = new Deferred;
return $this->pendingRead->promise();
@ -132,7 +132,8 @@ class Message implements InputStream, Promise {
$deferred = $this->pendingRead;
$this->pendingRead = null;
$deferred->resolve($this->buffer === "" ? $this->buffer : null);
$this->buffer = "";
}
$this->buffer = "";
}
}