File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,12 @@ PHP_FUNCTION(http_response_code)
375
375
}
376
376
RETURN_FALSE ;
377
377
}
378
+
379
+ if (SG (sapi_headers ).http_status_line ) {
380
+ efree (SG (sapi_headers ).http_status_line );
381
+ SG (sapi_headers ).http_status_line = NULL ;
382
+ }
383
+
378
384
zend_long old_response_code ;
379
385
380
386
old_response_code = SG (sapi_headers ).http_response_code ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-18582: Allow http_response_code() to clear HTTP start-line
3
+ --SKIPIF--
4
+ <?php
5
+ include "skipif.inc " ;
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ include "php_cli_server.inc " ;
10
+
11
+ php_cli_server_start (<<<'PHP'
12
+ http_response_code(401);
13
+ header('HTTP/1.1 404 Not Found');
14
+ $is_404 = http_response_code(403);
15
+ $should_be_404_but_is_403 = http_response_code();
16
+ echo $is_404 . PHP_EOL;
17
+ echo $should_be_404_but_is_403 . PHP_EOL;
18
+ PHP);
19
+
20
+ $ host = PHP_CLI_SERVER_HOSTNAME ;
21
+ $ fp = php_cli_server_connect ();
22
+ if (fwrite ($ fp , "GET / HTTP/1.1 \nHost: {$ host }\n\n" )) {
23
+ while (!feof ($ fp )) {
24
+ echo fgets ($ fp );
25
+ }
26
+ }
27
+ fclose ($ fp );
28
+ ?>
29
+ --EXPECTF--
30
+ HTTP/1.1 403 Forbidden
31
+ Host: %s
32
+ Date: %s
33
+ Connection: close
34
+ X-Powered-By: %s
35
+ Content-type: text/html; charset=UTF-8
36
+
37
+ 404
38
+ 403
You can’t perform that action at this time.
0 commit comments