mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
improve date header code
This commit is contained in:
parent
a7c0ba2e89
commit
d122f4c24a
1 changed files with 16 additions and 14 deletions
|
@ -340,21 +340,23 @@ 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);
|
||||
}
|
||||
time_t t;
|
||||
time(&t);
|
||||
zend_string *dt = php_format_date("r", 1, t, 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);
|
||||
|
||||
smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent);
|
||||
} /* }}} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue