Skip to content

Commit 4e32ecb

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fix #64878: 304 responses return Content-Type header
2 parents 692d283 + 0730fc8 commit 4e32ecb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,9 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client
20832083
if (!is_static_file) {
20842084
if (SUCCESS == php_cli_server_dispatch_script(server, client)
20852085
|| SUCCESS != php_cli_server_send_error_page(server, client, 500)) {
2086+
if (SG(sapi_headers).http_response_code == 304) {
2087+
SG(sapi_headers).send_default_content_type = 0;
2088+
}
20862089
php_cli_server_request_shutdown(server, client);
20872090
return SUCCESS;
20882091
}

sapi/cli/tests/bug64878.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #64878 (304 responses return Content-Type header)
3+
--INI--
4+
allow_url_fopen=1
5+
--SKIPIF--
6+
<?php
7+
include "skipif.inc";
8+
?>
9+
--FILE--
10+
<?php
11+
include "php_cli_server.inc";
12+
php_cli_server_start('header("HTTP/1.1 304 Not Modified")', null);
13+
$headers = get_headers('http://' . PHP_CLI_SERVER_ADDRESS);
14+
echo count(array_filter($headers, function ($value) {
15+
return stripos($value, 'Content-Type') === 0;
16+
}));
17+
?>
18+
--EXPECT--
19+
0

0 commit comments

Comments
 (0)