public function testApiDrain_EmptiesBuffer() { $result = $this->buffer->drain(); $this->assertSame($this->initialString, $result); $this->assertSame('', (string) $this->buffer); $this->assertTrue($this->buffer->isEmpty()); }
/** * @override */ public function readResponse(BufferInterface $buffer, $data) { $buffer->push($data); if (($position = $buffer->search(self::HTTP_EOM)) === false) { if ($buffer->length() > $this->maxStartLineLength) { throw new IoReadException(sprintf('Message start line exceeded maximum size of %d bytes.', $this->maxStartLineLength)); } return null; } try { $response = $this->parser->parseResponse($buffer->drain()); } catch (Error $ex) { throw new InvalidFormatException('Could not parse start line.'); } catch (Exception $ex) { throw new InvalidFormatException('Could not parse start line.'); } return $response; }