com php-src: Fix #64878: 304 responses return Content-Type header: sapi/cli/php_cli_server.c sapi/cli/tests/bug648 78.phpt
| From: | Christoph Michael Becker | Date: | Sat, 27 Jun 2015 12:28:33 +0000 |
| Subject: | com php-src: Fix #64878: 304 responses return Content-Type header: sapi/cli/php_cli_server.c sapi/cli/tests/bug648 78.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87558@lists.php.net to get a copy of this message | ||
Commit: 1920ba6f7bd1ce3c866ca947f51a1633dc892fce
Author: Christoph M. Becker <cmbecker69@gmx.de> Mon, 18 May 2015 21:28:22 +0200
Committer: Christoph M. Becker <cmb@php.net> Sat, 27 Jun 2015 14:28:33 +0200
Parents: 6400ef192c7c50faf47e958141aac8142a1cef99
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1920ba6f7bd1ce3c866ca947f51a1633dc892fce
Log:
Fix #64878: 304 responses return Content-Type header
According to RFC 7232 304 responses should not send a Content-Type header,
so the CLI server should comply.
Bugs:
https://bugs.php.net/64878
Changed paths:
M sapi/cli/php_cli_server.c
A sapi/cli/tests/bug64878.phpt
Diff:
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 3b5fe05..3214a2b 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2185,6 +2185,9 @@ static int php_cli_server_dispatch(php_cli_server *server,
php_cli_server_client
if (!is_static_file) {
if (SUCCESS == php_cli_server_dispatch_script(server, client TSRMLS_CC)
|| SUCCESS != php_cli_server_send_error_page(server, client, 500 TSRMLS_CC)) {
+ if (SG(sapi_headers).http_response_code == 304) {
+ SG(sapi_headers).send_default_content_type = 0;
+ }
php_cli_server_request_shutdown(server, client TSRMLS_CC);
return SUCCESS;
}
diff --git a/sapi/cli/tests/bug64878.phpt b/sapi/cli/tests/bug64878.phpt
new file mode 100644
index 0000000..cdaf520
--- /dev/null
+++ b/sapi/cli/tests/bug64878.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #64878 (304 responses return Content-Type header)
+--INI--
+allow_url_fopen=1
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start('header("HTTP/1.1 304 Not Modified")', null);
+$headers = get_headers('http://' . PHP_CLI_SERVER_ADDRESS);
+echo count(array_filter($headers, function ($value) {
+ return stripos($value, 'Content-Type') === 0;
+}));
+?>
+--EXPECT--
+0