@@ -64,14 +64,22 @@ public function setUpBrowserAndServer()
6464 );
6565 }
6666
67- if ($ path === '/status/300 ' ) {
67+ if ($ path === '/status/204 ' ) {
6868 return new Response (
69- 300 ,
69+ 204 ,
7070 array (),
7171 ''
7272 );
7373 }
7474
75+ if ($ path === '/status/304 ' ) {
76+ return new Response (
77+ 304 ,
78+ array (),
79+ 'Not modified '
80+ );
81+ }
82+
7583 if ($ path === '/status/404 ' ) {
7684 return new Response (
7785 404 ,
@@ -308,12 +316,24 @@ public function testFollowRedirectsZeroRejectsOnRedirect()
308316 Block \await ($ browser ->get ($ this ->base . 'redirect-to?url=get ' ), $ this ->loop );
309317 }
310318
311- /**
312- * @doesNotPerformAssertions
313- */
314- public function testResponseStatus300WithoutLocationShouldResolveWithoutFollowingRedirect ()
319+ public function testResponseStatus204ShouldResolveWithEmptyBody ()
315320 {
316- Block \await ($ this ->browser ->get ($ this ->base . 'status/300 ' ), $ this ->loop );
321+ $ response = Block \await ($ this ->browser ->get ($ this ->base . 'status/204 ' ), $ this ->loop );
322+ $ this ->assertFalse ($ response ->hasHeader ('Content-Length ' ));
323+
324+ $ body = $ response ->getBody ();
325+ $ this ->assertEquals (0 , $ body ->getSize ());
326+ $ this ->assertEquals ('' , (string ) $ body );
327+ }
328+
329+ public function testResponseStatus304ShouldResolveWithEmptyBodyButContentLengthResponseHeader ()
330+ {
331+ $ response = Block \await ($ this ->browser ->get ($ this ->base . 'status/304 ' ), $ this ->loop );
332+ $ this ->assertEquals ('12 ' , $ response ->getHeaderLine ('Content-Length ' ));
333+
334+ $ body = $ response ->getBody ();
335+ $ this ->assertEquals (0 , $ body ->getSize ());
336+ $ this ->assertEquals ('' , (string ) $ body );
317337 }
318338
319339 /**
@@ -595,9 +615,33 @@ public function testSendsExplicitHttp10Request()
595615 public function testHeadRequestReceivesResponseWithEmptyBodyButWithContentLengthResponseHeader ()
596616 {
597617 $ response = Block \await ($ this ->browser ->head ($ this ->base . 'get ' ), $ this ->loop );
598- $ this ->assertEquals ('' , (string )$ response ->getBody ());
599- $ this ->assertEquals (0 , $ response ->getBody ()->getSize ());
600618 $ this ->assertEquals ('5 ' , $ response ->getHeaderLine ('Content-Length ' ));
619+
620+ $ body = $ response ->getBody ();
621+ $ this ->assertEquals (0 , $ body ->getSize ());
622+ $ this ->assertEquals ('' , (string ) $ body );
623+ }
624+
625+ public function testRequestStreamingGetReceivesResponseWithStreamingBodyAndKnownSize ()
626+ {
627+ $ response = Block \await ($ this ->browser ->requestStreaming ('GET ' , $ this ->base . 'get ' ), $ this ->loop );
628+ $ this ->assertEquals ('5 ' , $ response ->getHeaderLine ('Content-Length ' ));
629+
630+ $ body = $ response ->getBody ();
631+ $ this ->assertEquals (5 , $ body ->getSize ());
632+ $ this ->assertEquals ('' , (string ) $ body );
633+ $ this ->assertInstanceOf ('React\Stream\ReadableStreamInterface ' , $ body );
634+ }
635+
636+ public function testRequestStreamingGetReceivesResponseWithStreamingBodyAndUnknownSizeFromStreamingEndpoint ()
637+ {
638+ $ response = Block \await ($ this ->browser ->requestStreaming ('GET ' , $ this ->base . 'stream/1 ' ), $ this ->loop );
639+ $ this ->assertFalse ($ response ->hasHeader ('Content-Length ' ));
640+
641+ $ body = $ response ->getBody ();
642+ $ this ->assertNull ($ body ->getSize ());
643+ $ this ->assertEquals ('' , (string ) $ body );
644+ $ this ->assertInstanceOf ('React\Stream\ReadableStreamInterface ' , $ body );
601645 }
602646
603647 public function testRequestStreamingGetReceivesStreamingResponseBody ()
0 commit comments