File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,7 +132,13 @@ public function handleData($data)
132132 $ this ->buffer .= $ data ;
133133
134134 if (false !== strpos ($ this ->buffer , "\r\n\r\n" )) {
135- list ($ response , $ bodyChunk ) = $ this ->parseResponse ($ this ->buffer );
135+ try {
136+ list ($ response , $ bodyChunk ) = $ this ->parseResponse ($ this ->buffer );
137+ } catch (\InvalidArgumentException $ exception ) {
138+ $ this ->emit ('error ' , [$ exception , $ this ]);
139+
140+ return ;
141+ }
136142
137143 $ this ->buffer = null ;
138144
Original file line number Diff line number Diff line change @@ -220,6 +220,28 @@ public function requestShouldEmitErrorIfConnectionEmitsError()
220220 $ request ->handleError (new \Exception ('test ' ));
221221 }
222222
223+ /** @test */
224+ public function requestShouldEmitErrorIfGuzzleParseThrowsException ()
225+ {
226+ $ requestData = new RequestData ('GET ' , 'http://www.example.com ' );
227+ $ request = new Request ($ this ->connector , $ requestData );
228+
229+ $ this ->successfulConnectionMock ();
230+
231+ $ handler = $ this ->createCallableMock ();
232+ $ handler ->expects ($ this ->once ())
233+ ->method ('__invoke ' )
234+ ->with (
235+ $ this ->isInstanceOf ('\InvalidArgumentException ' ),
236+ $ this ->isInstanceOf ('React\HttpClient\Request ' )
237+ );
238+
239+ $ request ->on ('error ' , $ handler );
240+
241+ $ request ->writeHead ();
242+ $ request ->handleData ("\r\n\r\n" );
243+ }
244+
223245 /**
224246 * @test
225247 * @expectedException Exception
You can’t perform that action at this time.
0 commit comments