From 7127a290ac1eda5293d5b3ceea5e04c385a8a564 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 8 Jan 2024 13:44:36 +0100 Subject: [PATCH] Add X-Powered-By header to builtin 404 page As requested by https://github.com/php/php-src/pull/12992/files/30929c9a887ef7917a346bfeb76c82274ad31aca#r1434156785. --- sapi/cli/php_cli_server.c | 1 + sapi/cli/tests/php_cli_server_013.phpt | 6 ++++++ sapi/cli/tests/php_cli_server_014.phpt | 1 + 3 files changed, 8 insertions(+) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index a09f273a7022..2b4655a47488 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -2065,6 +2065,7 @@ static zend_result php_cli_server_send_error_page(php_cli_server *server, php_cl goto fail; } append_essential_headers(&buffer, client, 1, NULL); + smart_str_appends_ex(&buffer, SAPI_PHP_VERSION_HEADER "\r\n", 1); smart_str_appends_ex(&buffer, "Content-Type: text/html; charset=UTF-8\r\n", 1); smart_str_appends_ex(&buffer, "Content-Length: ", 1); smart_str_append_unsigned_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), 1); diff --git a/sapi/cli/tests/php_cli_server_013.phpt b/sapi/cli/tests/php_cli_server_013.phpt index 11e3fdf065b1..fb334206908a 100644 --- a/sapi/cli/tests/php_cli_server_013.phpt +++ b/sapi/cli/tests/php_cli_server_013.phpt @@ -127,6 +127,7 @@ HTTP/1.1 404 Not Found Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d @@ -136,6 +137,7 @@ HTTP/1.1 404 Not Found Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d @@ -145,6 +147,7 @@ HTTP/1.1 404 Not Found Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d @@ -153,6 +156,7 @@ HTTP/1.1 405 Method Not Allowed Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d Allow: GET, HEAD, POST @@ -163,6 +167,7 @@ HTTP/1.1 405 Method Not Allowed Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d Allow: GET, HEAD, POST @@ -173,6 +178,7 @@ HTTP/1.1 405 Method Not Allowed Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: text/html; charset=UTF-8 Content-Length: %d Allow: GET, HEAD, POST diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt index b29a01437399..eb42bf3e8d5b 100644 --- a/sapi/cli/tests/php_cli_server_014.phpt +++ b/sapi/cli/tests/php_cli_server_014.phpt @@ -65,6 +65,7 @@ HTTP/1.1 404 Not Found Host: %s Date: %s Connection: close +X-Powered-By: PHP/%s Content-Type: %s Content-Length: %d