diff options
author | Jakub Zelenka <bukka@php.net> | 2016-06-19 17:05:48 +0100 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2016-06-19 17:05:48 +0100 |
commit | e63a8540a60e95aa5bd8e269add1b02afcc1b79b (patch) | |
tree | b83a144eec24cc81adab0b9a778f7a730d8df79e /sapi/cli/php_cli_server.c | |
parent | 7a4cc73641bb3eb878f7184bcbd026ee663cf2a9 (diff) | |
parent | 53071e647049f099f7f7a0771ddb63fc2cdd621c (diff) | |
download | php-git-e63a8540a60e95aa5bd8e269add1b02afcc1b79b.tar.gz |
Merge branch 'openssl_error_store' into openssl_aead
Diffstat (limited to 'sapi/cli/php_cli_server.c')
-rw-r--r-- | sapi/cli/php_cli_server.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index ac41c44def..a9d4a533b3 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -96,6 +96,7 @@ #include "ext/standard/html.h" #include "ext/standard/url.h" /* for php_raw_url_decode() */ #include "ext/standard/php_string.h" /* for php_dirname() */ +#include "ext/date/php_date.h" /* for php_format_date() */ #include "php_network.h" #include "php_http_parser.h" @@ -339,15 +340,24 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, int persistent) /* {{{ */ { - { - char *val; - if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { - smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); - smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); - smart_str_appends_ex(buffer, val, persistent); - smart_str_appendl_ex(buffer, "\r\n", 2, persistent); - } + char *val; + struct timeval tv = {0}; + + if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) { + smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent); + smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent); + smart_str_appends_ex(buffer, val, persistent); + smart_str_appendl_ex(buffer, "\r\n", 2, persistent); } + + if (!gettimeofday(&tv, NULL)) { + zend_string *dt = php_format_date("r", 1, tv.tv_sec, 1); + smart_str_appendl_ex(buffer, "Date: ", 6, persistent); + smart_str_appends_ex(buffer, dt->val, persistent); + smart_str_appendl_ex(buffer, "\r\n", 2, persistent); + zend_string_release(dt); + } + smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent); } /* }}} */ @@ -1964,7 +1974,7 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv if (client->request.path_translated && ('.' == client->request.path_translated[client->request.path_translated_len-1] || ' ' == client->request.path_translated[client->request.path_translated_len-1])) { - return php_cli_server_send_error_page(server, client, 500); + return php_cli_server_send_error_page(server, client, 500 TSRMLS_CC); } #endif |