/** @test */ public function chunkedEncodingResponse() { $stream = new ThroughStream(); $response = new Response($stream, 'http', '1.0', '200', 'ok', ['content-type' => 'text/plain', 'transfer-encoding' => 'chunked']); $buffer = ''; $response->on('data', function ($data, $stream) use(&$buffer) { $buffer .= $data; }); $this->assertSame('', $buffer); $stream->write("4; abc=def\r\n"); $this->assertSame('', $buffer); $stream->write("Wiki\r\n"); $this->assertSame('Wiki', $buffer); $this->assertSame(['content-type' => 'text/plain'], $response->getHeaders()); }
/** @test */ public function pipeShouldPipeCorrectly() { $output = $this->getMock('React\\Stream\\WritableStreamInterface'); $output->expects($this->once())->method('write')->with('foo'); $through = new ThroughStream(); $through->pipe($output); $through->write('foo'); }
public function __construct() { $this->fd = uniqid(); parent::__construct(); }
/** * Constructor * * @param string $key */ public function __construct($key) { parent::__construct(); $this->transformer = new VigenereCipherTransformer($key); }
public function testHandleEndEnsureNoError() { $ended = false; $stream = new ThroughStream(); $response = new ChunkedStreamDecoder($stream); $response->on('error', function ($error) { $this->fail((string) $error); }); $response->on('end', function () use(&$ended) { $ended = true; }); $stream->write("4\r\nWiki\r\n"); $stream->write("0\r\n\r\n"); $stream->end(); $this->assertTrue($ended); }
public function __construct($prefix) { parent::__construct(); $this->prefix = $prefix; }
/** * Write only debug data passed to stream * * @param string $data */ public function write($data) { if ($this->level === self::DEBUG) { parent::write($data); } }