File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,14 @@ public function __construct($requestHandlerOrLoop)
247
247
248
248
$ middleware = \array_merge ($ middleware , $ requestHandlers );
249
249
250
+ /**
251
+ * Filter out any configuration middleware, no need to run requests through something that isn't
252
+ * doing anything with the request.
253
+ */
254
+ $ middleware = \array_filter ($ middleware , function ($ handler ) {
255
+ return !($ handler instanceof StreamingRequestMiddleware);
256
+ });
257
+
250
258
$ this ->streamingServer = new StreamingServer ($ loop , new MiddlewareRunner ($ middleware ));
251
259
252
260
$ that = $ this ;
Original file line number Diff line number Diff line change @@ -431,4 +431,27 @@ public function testConstructServerWithMemoryLimitDoesLimitConcurrency()
431
431
$ this ->assertTrue (is_array ($ middleware ));
432
432
$ this ->assertInstanceOf ('React\Http\Middleware\LimitConcurrentRequestsMiddleware ' , $ middleware [0 ]);
433
433
}
434
+
435
+ public function testConstructFiltersOutConfigurationMiddlewareBefore ()
436
+ {
437
+ $ http = new HttpServer (new StreamingRequestMiddleware (), function () { });
438
+
439
+ $ ref = new \ReflectionProperty ($ http , 'streamingServer ' );
440
+ $ ref ->setAccessible (true );
441
+
442
+ $ streamingServer = $ ref ->getValue ($ http );
443
+
444
+ $ ref = new \ReflectionProperty ($ streamingServer , 'callback ' );
445
+ $ ref ->setAccessible (true );
446
+
447
+ $ middlewareRunner = $ ref ->getValue ($ streamingServer );
448
+
449
+ $ ref = new \ReflectionProperty ($ middlewareRunner , 'middleware ' );
450
+ $ ref ->setAccessible (true );
451
+
452
+ $ middleware = $ ref ->getValue ($ middlewareRunner );
453
+
454
+ $ this ->assertTrue (is_array ($ middleware ));
455
+ $ this ->assertCount (1 , $ middleware );
456
+ }
434
457
}
You can’t perform that action at this time.
0 commit comments