xref: /PHP-8.4/ext/standard/tests/http/bug80838.phpt (revision 47a199c8)
1--TEST--
2Bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101)
3--INI--
4allow_url_fopen=1
5--SKIPIF--
6<?php require 'server.inc'; http_server_skipif(); ?>
7--FILE--
8<?php
9require '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
26var_dump(http_get_last_response_headers());
27
28$fd = fopen($uri, 'rb', false, $ctx);
29fclose($fd);
30var_dump($http_response_header);
31var_dump(http_get_last_response_headers());
32
33http_server_kill($pid);
34
35?>
36--EXPECT--
37NULL
38array(3) {
39  [0]=>
40  string(32) "HTTP/1.1 101 Switching Protocols"
41  [1]=>
42  string(15) "Header1: Value1"
43  [2]=>
44  string(15) "Header2: Value2"
45}
46array(3) {
47  [0]=>
48  string(32) "HTTP/1.1 101 Switching Protocols"
49  [1]=>
50  string(15) "Header1: Value1"
51  [2]=>
52  string(15) "Header2: Value2"
53}
54