From 1920ba6f7bd1ce3c866ca947f51a1633dc892fce Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 18 May 2015 21:28:22 +0200 Subject: [PATCH] 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. --- sapi/cli/php_cli_server.c | 3 +++ sapi/cli/tests/bug64878.phpt | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 sapi/cli/tests/bug64878.phpt diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 3b5fe059456..3214a2bba13 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 00000000000..cdaf520f0f8 --- /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-- + +--FILE-- + +--EXPECT-- +0