/** * {@inheritdoc} */ public function discard() : Awaitable { return new Coroutine(function () { $len = 0; try { while (null !== ($chunk = (yield $this->stream->read()))) { $len += \strlen($chunk); } return $len; } finally { $this->stream->close(); } }); }
/** * {@inheritdoc} */ public function discard() : Awaitable { return new Coroutine(function () { if ($this->decodedStream === null) { $this->decodedStream = $this->createInputStream(); } $len = 0; try { if ($this->expectContinue === null || $this->decodedStream->isContinued()) { while (null !== ($chunk = (yield $this->decodedStream->read()))) { $len += \strlen($chunk); } } return $len; } finally { $this->decodedStream->close(); } }); }