File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -504,14 +504,14 @@ protected function setResponseHeaders(array $headers = [])
504504 $ this ->response ->setHeader ($ title , $ value );
505505 }
506506 } elseif (str_starts_with ($ header , 'HTTP ' )) {
507- preg_match ('#^HTTP\/([12](?:\.[01])?) (\d+) (.+)# ' , $ header , $ matches );
507+ preg_match ('#^HTTP\/([12](?:\.[01])?) (\d+)(?: (.+))? # ' , $ header , $ matches );
508508
509509 if (isset ($ matches [1 ])) {
510510 $ this ->response ->setProtocolVersion ($ matches [1 ]);
511511 }
512512
513513 if (isset ($ matches [2 ])) {
514- $ this ->response ->setStatusCode ((int ) $ matches [2 ], $ matches [3 ] ?? null );
514+ $ this ->response ->setStatusCode ((int ) $ matches [2 ], $ matches [3 ] ?? '' );
515515 }
516516 }
517517 }
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ public function testArrayAccessOfCookie(): void
301301 $ this ->assertSame ($ cookie ['path ' ], $ cookie ->getPath ());
302302
303303 $ this ->expectException ('InvalidArgumentException ' );
304- $ cookie ['expiry ' ]; // @phpstan-ignore expr.resultUnused
304+ $ cookie ['expiry ' ];
305305 }
306306
307307 public function testCannotSetPropertyViaArrayAccess (): void
Original file line number Diff line number Diff line change @@ -1041,6 +1041,23 @@ public function testResponseHeadersShortProtocol(): void
10411041 $ this ->assertSame (235 , $ response ->getStatusCode ());
10421042 }
10431043
1044+ public function testResponseHeadersWithoutReasonPhrase (): void
1045+ {
1046+ // HTTP/2 does not include a reason phrase per RFC 7540.
1047+ // curl synthesizes the status line as "HTTP/2 200" with no trailing reason.
1048+ $ request = $ this ->getRequest ([
1049+ 'baseURI ' => 'http://www.foo.com/api/v1/ ' ,
1050+ 'delay ' => 100 ,
1051+ ]);
1052+
1053+ $ request ->setOutput ("HTTP/2 200 \x0d\x0aContent-Type: text/html \x0d\x0a\x0d\x0aHi there " );
1054+ $ response = $ request ->get ('bogus ' );
1055+
1056+ $ this ->assertSame ('2.0 ' , $ response ->getProtocolVersion ());
1057+ $ this ->assertSame (200 , $ response ->getStatusCode ());
1058+ $ this ->assertSame ('OK ' , $ response ->getReasonPhrase ());
1059+ }
1060+
10441061 public function testPostFormEncoded (): void
10451062 {
10461063 $ params = [
You can’t perform that action at this time.
0 commit comments