Skip to content

Commit 8d58504

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2 parents 495bf5c + 3880b87 commit 8d58504

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
678678
/* status codes of 1xx are "informational", and will be followed by a real response
679679
* e.g "100 Continue". RFC 7231 states that unexpected 1xx status MUST be parsed,
680680
* and MAY be ignored. As such, we need to skip ahead to the "real" status*/
681-
if (response_code >= 100 && response_code < 200) {
681+
if (response_code >= 100 && response_code < 200 && response_code != 101) {
682682
/* consume lines until we find a line starting 'HTTP/1' */
683683
while (
684684
!php_stream_eof(stream)

ext/standard/tests/http/bug80838.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101)
3+
--INI--
4+
allow_url_fopen=1
5+
--SKIPIF--
6+
<?php require 'server.inc'; http_server_skipif(); ?>
7+
--FILE--
8+
<?php
9+
require 'server.inc';
10+
11+
$responses = [
12+
"data://text/plain,HTTP/1.1 101 Switching Protocols\r\nHeader1: Value1\r\nHeader2: Value2\r\n\r\n"
13+
. "Hello from another protocol"
14+
];
15+
16+
['pid' => $pid, 'uri' => $uri] = http_server($responses);
17+
18+
$options = [
19+
'http' => [
20+
'ignore_errors' => true
21+
],
22+
];
23+
24+
$ctx = stream_context_create($options);
25+
26+
$fd = fopen($uri, 'rb', false, $ctx);
27+
fclose($fd);
28+
var_dump($http_response_header);
29+
30+
http_server_kill($pid);
31+
32+
?>
33+
--EXPECT--
34+
array(3) {
35+
[0]=>
36+
string(32) "HTTP/1.1 101 Switching Protocols"
37+
[1]=>
38+
string(15) "Header1: Value1"
39+
[2]=>
40+
string(15) "Header2: Value2"
41+
}

0 commit comments

Comments
 (0)