xref: /PHP-8.4/ext/standard/tests/http/gh9316.phpt (revision 47a199c8)
1--TEST--
2Bug GH-9316 ($http_response_header is wrong for long status line)
3--SKIPIF--
4<?php require 'server.inc'; http_server_skipif(); ?>
5--INI--
6allow_url_fopen=1
7--FILE--
8<?php
9require 'server.inc';
10
11$responses = array(
12    "data://text/plain,HTTP/1.1 200 Some very long reason-phrase to test that this is properly handled by our code without adding a new header like  Bad: Header\r\nGood: Header\r\n\r\nBody",
13    "data://text/plain,HTTP/1.1 200 \r\nGood: Header\r\n\r\nBody",
14);
15
16['pid' => $pid, 'uri' => $uri] = http_server($responses, $output);
17
18for ($i = 0; $i < count($responses); ++$i) {
19    echo 'http_get_last_response_headers() before stream layer call:', PHP_EOL;
20    var_dump(http_get_last_response_headers());
21
22    $f = @fopen($uri, "r");
23    echo '$http_response_header', PHP_EOL;
24    var_dump($http_response_header);
25    echo 'http_get_last_response_headers() after stream layer call:', PHP_EOL;
26    var_dump(http_get_last_response_headers());
27    fclose($f);
28}
29
30http_server_kill($pid);
31
32?>
33--EXPECT--
34http_get_last_response_headers() before stream layer call:
35NULL
36$http_response_header
37array(2) {
38  [0]=>
39  string(126) "HTTP/1.1 200 Some very long reason-phrase to test that this is properly handled by our code without adding a new header like  "
40  [1]=>
41  string(12) "Good: Header"
42}
43http_get_last_response_headers() after stream layer call:
44array(2) {
45  [0]=>
46  string(126) "HTTP/1.1 200 Some very long reason-phrase to test that this is properly handled by our code without adding a new header like  "
47  [1]=>
48  string(12) "Good: Header"
49}
50http_get_last_response_headers() before stream layer call:
51array(2) {
52  [0]=>
53  string(126) "HTTP/1.1 200 Some very long reason-phrase to test that this is properly handled by our code without adding a new header like  "
54  [1]=>
55  string(12) "Good: Header"
56}
57$http_response_header
58array(2) {
59  [0]=>
60  string(13) "HTTP/1.1 200 "
61  [1]=>
62  string(12) "Good: Header"
63}
64http_get_last_response_headers() after stream layer call:
65array(2) {
66  [0]=>
67  string(13) "HTTP/1.1 200 "
68  [1]=>
69  string(12) "Good: Header"
70}
71