mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
No Content-Type header if MIME type is unknown
This commit is contained in:
parent
0c80cb164f
commit
193c02875a
1 changed files with 7 additions and 8 deletions
|
@ -2031,9 +2031,6 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
|
|||
php_cli_server_chunk *chunk;
|
||||
smart_str buffer = { 0 };
|
||||
const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len);
|
||||
if (!mime_type) {
|
||||
mime_type = "application/octet-stream";
|
||||
}
|
||||
|
||||
append_http_status_line(&buffer, client->request.protocol_version, status, 1);
|
||||
if (!buffer.s) {
|
||||
|
@ -2042,12 +2039,14 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
|
|||
return FAILURE;
|
||||
}
|
||||
append_essential_headers(&buffer, client, 1);
|
||||
smart_str_appendl_ex(&buffer, "Content-Type: ", sizeof("Content-Type: ") - 1, 1);
|
||||
smart_str_appends_ex(&buffer, mime_type, 1);
|
||||
if (strncmp(mime_type, "text/", 5) == 0) {
|
||||
smart_str_appends_ex(&buffer, "; charset=UTF-8", 1);
|
||||
if (mime_type) {
|
||||
smart_str_appendl_ex(&buffer, "Content-Type: ", sizeof("Content-Type: ") - 1, 1);
|
||||
smart_str_appends_ex(&buffer, mime_type, 1);
|
||||
if (strncmp(mime_type, "text/", 5) == 0) {
|
||||
smart_str_appends_ex(&buffer, "; charset=UTF-8", 1);
|
||||
}
|
||||
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
|
||||
}
|
||||
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
|
||||
smart_str_appends_ex(&buffer, "Content-Length: ", 1);
|
||||
smart_str_append_unsigned_ex(&buffer, client->request.sb.st_size, 1);
|
||||
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue