@@ -1205,6 +1205,42 @@ public function testEndEventWillBeEmittedOnSimpleRequest()
12051205 $ this ->connection ->emit ('data ' , array ($ data ));
12061206 }
12071207
1208+ public function testRequestWithIncompleteHeaderWontEmitRequestEvent ()
1209+ {
1210+ $ server = new Server ($ this ->socket );
1211+ $ server ->on ('request ' , $ this ->expectCallableNever ());
1212+
1213+ $ this ->socket ->emit ('connection ' , array ($ this ->connection ));
1214+
1215+ $ data = "GET / HTTP/1.1 \r\n" ;
1216+
1217+ $ this ->connection ->emit ('data ' , array ($ data ));
1218+ }
1219+
1220+ public function testRequestWithoutDefinedLengthWillIgnoreDataEvent ()
1221+ {
1222+ $ server = new Server ($ this ->socket );
1223+
1224+ $ dataEvent = $ this ->expectCallableNever ();
1225+ $ endEvent = $ this ->expectCallableOnce ();
1226+ $ closeEvent = $ this ->expectCallableOnce ();
1227+ $ errorEvent = $ this ->expectCallableNever ();
1228+
1229+ $ server ->on ('request ' , function (Request $ request , Response $ response ) use ($ dataEvent , $ endEvent , $ closeEvent , $ errorEvent ) {
1230+ $ request ->on ('data ' , $ dataEvent );
1231+ $ request ->on ('end ' , $ endEvent );
1232+ $ request ->on ('close ' , $ closeEvent );
1233+ $ request ->on ('error ' , $ errorEvent );
1234+ });
1235+
1236+ $ this ->socket ->emit ('connection ' , array ($ this ->connection ));
1237+
1238+ $ data = $ this ->createGetRequest ();
1239+ $ data .= "hello world " ;
1240+
1241+ $ this ->connection ->emit ('data ' , array ($ data ));
1242+ }
1243+
12081244 private function createGetRequest ()
12091245 {
12101246 $ data = "GET / HTTP/1.1 \r\n" ;
0 commit comments