| // Forward occuring errors on to request | ||
| $stream->on('error', function ($error) use ($request) { | ||
| $request->emit('error', array($error)); | ||
| }); |
| use React\Stream\Util; | ||
|
|
||
| /** @internal */ | ||
| class CloseProtectionStream extends EventEmitter implements ReadableStreamInterface |
|
|
||
| class CloseProtectionStreamTest extends TestCase | ||
| { | ||
| public function testCloseEventDoesntCloseInputStream() |
| $input->expects($this->once())->method('pause'); | ||
|
|
||
| $protection = new CloseProtectionStream($input); | ||
| $protection->pause(); |
| public function handleError(\Exception $e) | ||
| { | ||
| $this->emit('error', array($e)); | ||
| $this->close(); |
| $protection->on('close', $this->expectCallableOnce()); | ||
|
|
||
| $input->close(); | ||
| $input->emit('end', array()); |
| $input->emit('end', array()); | ||
|
|
||
| $this->assertFalse($protection->isReadable()); | ||
| } |
| $this->emit('close'); | ||
|
|
||
| // 'pause' the stream avoids additional traffic transferred by this stream | ||
| $this->input->pause(); |
| $server->on('request', function ($request, $response) use (&$error){ | ||
| $request->on('error', function ($ex) use (&$error) { | ||
| $error = $ex; | ||
| }); |
| $this->assertInstanceOf('InvalidArgumentException', $error); | ||
| } | ||
|
|
||
| public function testInvalidChunkHeaderResultsInErrorResponse() |
| $input->expects($this->once())->method('pause'); | ||
|
|
||
| $protection = new CloseProtectionStream($input); | ||
| $protection->pause(); |
| $protection->close(); | ||
| } | ||
|
|
||
| public function testPause() |
legionth
changed the title
Handle errors from ChunkedDecoder and LengthLimitedStream
Protect the TCP connection against close from other streams
clue approved these changes Mar 1, 2017
jsor approved these changes Mar 1, 2017