xref: /PHP-7.4/ext/standard/tests/http/bug80838.phpt (revision 5787f91c)
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('tcp://127.0.0.1:12342'); ?>
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 = http_server('tcp://127.0.0.1:12342', $responses);
17
18$options = [
19  'http' => [
20    'ignore_errors' => true
21  ],
22];
23
24$ctx = stream_context_create($options);
25
26$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx);
27fclose($fd);
28var_dump($http_response_header);
29
30http_server_kill($pid);
31
32?>
33--EXPECT--
34array(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}
42