File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public function handleConnection(ConnectionInterface $conn)
101101
102102 $ that ->writeError (
103103 $ conn ,
104- 400
104+ ( $ e instanceof \OverflowException) ? 431 : 400
105105 );
106106 });
107107 }
Original file line number Diff line number Diff line change @@ -308,21 +308,37 @@ function ($data) use (&$buffer) {
308308 $ this ->assertContains ("\r\n\r\nError 505: HTTP Version Not Supported " , $ buffer );
309309 }
310310
311- public function testParserErrorEmitted ()
311+ public function testRequestOverflowWillEmitErrorAndSendErrorResponse ()
312312 {
313313 $ error = null ;
314314 $ server = new Server ($ this ->socket );
315315 $ server ->on ('error ' , function ($ message ) use (&$ error ) {
316316 $ error = $ message ;
317317 });
318318
319+ $ buffer = '' ;
320+
321+ $ this ->connection
322+ ->expects ($ this ->any ())
323+ ->method ('write ' )
324+ ->will (
325+ $ this ->returnCallback (
326+ function ($ data ) use (&$ buffer ) {
327+ $ buffer .= $ data ;
328+ }
329+ )
330+ );
331+
319332 $ this ->socket ->emit ('connection ' , array ($ this ->connection ));
320333
321334 $ data = "GET / HTTP/1.1 \r\nHost: example.com \r\nConnection: close \r\nX-DATA: " ;
322335 $ data .= str_repeat ('A ' , 4097 - strlen ($ data )) . "\r\n\r\n" ;
323336 $ this ->connection ->emit ('data ' , array ($ data ));
324337
325338 $ this ->assertInstanceOf ('OverflowException ' , $ error );
339+
340+ $ this ->assertContains ("HTTP/1.1 431 Request Header Fields Too Large \r\n" , $ buffer );
341+ $ this ->assertContains ("\r\n\r\nError 431: Request Header Fields Too Large " , $ buffer );
326342 }
327343
328344 public function testRequestInvalidWillEmitErrorAndSendErrorResponse ()
You can’t perform that action at this time.
0 commit comments