diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2021-03-08 14:39:38 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2021-03-08 14:51:45 +0100 |
commit | 3880b8785be8cec394e7290e0ef4307be0ae596e (patch) | |
tree | 60d294cf19484d1237e13e2aa387b3a3042bf21e | |
parent | 0f8312342f3b0a639cd583b53ccdea56019d2685 (diff) | |
parent | 5787f91c55a7ebaeb34711d303cfc27f089f58b3 (diff) | |
download | php-git-3880b8785be8cec394e7290e0ef4307be0ae596e.tar.gz |
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/standard/http_fopen_wrapper.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/http/bug80838.phpt | 41 |
3 files changed, 44 insertions, 1 deletions
@@ -26,6 +26,8 @@ PHP NEWS . Fixed bug #80771 (phpinfo(INFO_CREDITS) displays nothing in CLI). (cmb) . Fixed bug #78719 (http wrapper silently ignores long Location headers). (cmb) + . Fixed bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101). + (manuelm) - Zip: . Fixed bug #80825 (ZipArchive::isCompressionMethodSupported does not exist). diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index ff132e7e0d..da822d9160 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -678,7 +678,7 @@ finish: /* status codes of 1xx are "informational", and will be followed by a real response * e.g "100 Continue". RFC 7231 states that unexpected 1xx status MUST be parsed, * and MAY be ignored. As such, we need to skip ahead to the "real" status*/ - if (response_code >= 100 && response_code < 200) { + if (response_code >= 100 && response_code < 200 && response_code != 101) { /* consume lines until we find a line starting 'HTTP/1' */ while ( !php_stream_eof(stream) diff --git a/ext/standard/tests/http/bug80838.phpt b/ext/standard/tests/http/bug80838.phpt new file mode 100644 index 0000000000..66f3113e1a --- /dev/null +++ b/ext/standard/tests/http/bug80838.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101) +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php require 'server.inc'; http_server_skipif(); ?> +--FILE-- +<?php +require 'server.inc'; + +$responses = [ + "data://text/plain,HTTP/1.1 101 Switching Protocols\r\nHeader1: Value1\r\nHeader2: Value2\r\n\r\n" + . "Hello from another protocol" +]; + +['pid' => $pid, 'uri' => $uri] = http_server($responses); + +$options = [ + 'http' => [ + 'ignore_errors' => true + ], +]; + +$ctx = stream_context_create($options); + +$fd = fopen($uri, 'rb', false, $ctx); +fclose($fd); +var_dump($http_response_header); + +http_server_kill($pid); + +?> +--EXPECT-- +array(3) { + [0]=> + string(32) "HTTP/1.1 101 Switching Protocols" + [1]=> + string(15) "Header1: Value1" + [2]=> + string(15) "Header2: Value2" +} |