File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public function handleConnection(ConnectionInterface $conn)
9090
9191 $ that ->writeError (
9292 $ conn ,
93- 400
93+ ( $ e instanceof \OverflowException) ? 431 : 400
9494 );
9595 });
9696 }
Original file line number Diff line number Diff line change @@ -202,21 +202,37 @@ function ($data) use (&$buffer) {
202202 $ this ->assertContains ("\r\nX-Powered-By: React/alpha \r\n" , $ buffer );
203203 }
204204
205- public function testParserErrorEmitted ()
205+ public function testRequestOverflowWillEmitErrorAndSendErrorResponse ()
206206 {
207207 $ error = null ;
208208 $ server = new Server ($ this ->socket );
209209 $ server ->on ('error ' , function ($ message ) use (&$ error ) {
210210 $ error = $ message ;
211211 });
212212
213+ $ buffer = '' ;
214+
215+ $ this ->connection
216+ ->expects ($ this ->any ())
217+ ->method ('write ' )
218+ ->will (
219+ $ this ->returnCallback (
220+ function ($ data ) use (&$ buffer ) {
221+ $ buffer .= $ data ;
222+ }
223+ )
224+ );
225+
213226 $ this ->socket ->emit ('connection ' , array ($ this ->connection ));
214227
215228 $ data = "GET / HTTP/1.1 \r\nHost: example.com \r\nConnection: close \r\nX-DATA: " ;
216229 $ data .= str_repeat ('A ' , 4097 - strlen ($ data )) . "\r\n\r\n" ;
217230 $ this ->connection ->emit ('data ' , array ($ data ));
218231
219232 $ this ->assertInstanceOf ('OverflowException ' , $ error );
233+
234+ $ this ->assertContains ("HTTP/1.1 431 Request Header Fields Too Large \r\n" , $ buffer );
235+ $ this ->assertContains ("\r\n\r\nError 431: Request Header Fields Too Large " , $ buffer );
220236 }
221237
222238 public function testRequestInvalidWillEmitErrorAndSendErrorResponse ()
You can’t perform that action at this time.
0 commit comments