From 9e24d1b8e899506b431a780ee1f2a7513708c847 Mon Sep 17 00:00:00 2001
From: manuel
Date: Sat, 6 Mar 2021 00:59:45 +0100
Subject: [PATCH] http_fopen_wrapper.c - Handle HTTP 101
Don't wait for further responses after a HTTP 101 (Switching Protocols) response
---
ext/standard/http_fopen_wrapper.c | 2 +-
ext/standard/tests/http/bug80838.phpt | 41 +++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 ext/standard/tests/http/bug80838.phpt
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index bf0363fd3cca..686126a212a8 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -680,7 +680,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
/* 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 = 100 && response_code
+--FILE--
+ [
+ 'ignore_errors' => true
+ ],
+];
+
+$ctx = stream_context_create($options);
+
+$fd = fopen('http://127.0.0.1:12342/', '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"
+}