Skip to content

Commit ed8ff1e

Browse files
CLI server: remove "Host" header reflection from response
The server previously responded with a copy of the requested "Host" header in the response, without any validation. That header, as defined in RFC 9110, is intended for use in *requests*; remove it from the responses.
1 parent 5bebadb commit ed8ff1e

36 files changed

Lines changed: 0 additions & 54 deletions

‎ext/curl/tests/curl_setopt_CURLOPT_WRITEHEADER.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ echo $header_contents, "\n";
2828
?>
2929
--EXPECTF--
3030
HTTP/1.1 200 OK
31-
Host: localhost:%d
3231
Date: %s
3332
Connection: close
3433
X-Powered-By: PHP/%s

‎ext/soap/tests/bugs/bug49278.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Content-Length: %d
5151

5252
"
5353
string(%s) "HTTP/1.1 200 OK
54-
Host: %s
5554
Date: %s
5655
Connection: close
5756
X-Powered-By: PHP/%s

‎sapi/cli/php_cli_server.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int
359359

360360
static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, bool persistent, sapi_headers_struct *sapi_headers) /* {{{ */
361361
{
362-
zval *val;
363362
struct timeval tv = {0};
364363
bool append_date_header = true;
365364

@@ -377,12 +376,6 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
377376
}
378377
}
379378

380-
if (NULL != (val = zend_hash_find(&client->request.headers, ZSTR_KNOWN(ZEND_STR_HOST)))) {
381-
smart_str_appends_ex(buffer, "Host: ", persistent);
382-
smart_str_append_ex(buffer, Z_STR_P(val), persistent);
383-
smart_str_appends_ex(buffer, "\r\n", persistent);
384-
}
385-
386379
if (append_date_header && !gettimeofday(&tv, NULL)) {
387380
zend_string *dt = php_format_date("D, d M Y H:i:s", sizeof("D, d M Y H:i:s") - 1, tv.tv_sec, 0);
388381
smart_str_appends_ex(buffer, "Date: ", persistent);

‎sapi/cli/tests/bug43177.phpt‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,25 @@ HEADER
5555
?>
5656
--EXPECTF--
5757
HTTP/1.1 200 OK
58-
Host: localhost
5958
Date: %s
6059
Connection: close
6160
X-Powered-By: %s
6261
Content-type: text/html; charset=UTF-8
6362

6463
OK
6564
HTTP/1.0 500 Internal Server Error
66-
Host: localhost
6765
Date: %s
6866
Connection: close
6967
X-Powered-By: %s
7068
Content-type: text/html; charset=UTF-8
7169

7270
HTTP/1.0 500 Internal Server Error
73-
Host: localhost
7471
Date: %s
7572
Connection: close
7673
X-Powered-By: %s
7774
Content-type: text/html; charset=UTF-8
7875

7976
HTTP/1.0 500 Internal Server Error
80-
Host: localhost
8177
Date: %s
8278
Connection: close
8379
X-Powered-By: %s

‎sapi/cli/tests/bug65066_100.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ HEADER
2828
?>
2929
--EXPECTF--
3030
HTTP/1.1 100 Continue
31-
Host: %s
3231
Date: %s
3332
Connection: close
3433
X-Powered-By: PHP/%s

‎sapi/cli/tests/bug65066_422.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ HEADER
2828
?>
2929
--EXPECTF--
3030
HTTP/1.1 422 Unknown Status Code
31-
Host: %s
3231
Date: %s
3332
Connection: close
3433
X-Powered-By: PHP/%s

‎sapi/cli/tests/bug65066_511.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ HEADER
2828
?>
2929
--EXPECTF--
3030
HTTP/1.1 511 Network Authentication Required
31-
Host: %s
3231
Date: %s
3332
Connection: close
3433
X-Powered-By: PHP/%s

‎sapi/cli/tests/bug66606_2.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fclose($fp);
3232
?>
3333
--EXPECTF--
3434
HTTP/1.1 200 OK
35-
Host: %s
3635
Date: %s
3736
Connection: close
3837
X-Powered-By: PHP/%s

‎sapi/cli/tests/bug66830.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ fclose($fp);
3131
?>
3232
--EXPECTF--
3333
HTTP/1.1 200 OK
34-
Host: %s
3534
Date: %s
3635
Connection: close
3736
X-Powered-By: %s

‎sapi/cli/tests/bug71005.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ HEADER
3333
?>
3434
--EXPECTF--
3535
HTTP/1.1 200 OK
36-
Host: %s
3736
Date: %s
3837
Connection: close
3938
X-Powered-By: PHP/%s

0 commit comments

Comments
 (0)