summaryrefslogtreecommitdiff
path: root/sapi/cli/php_cli_server.c
diff options
context:
space:
mode:
authorSeeSchloss <see@seos.fr>2016-01-21 17:20:24 +0000
committerAnatol Belski <ab@php.net>2016-06-02 12:27:48 +0200
commitf33c7b3e41bda272de83bcc4959b3e0b968e3124 (patch)
treeb7ff5397f9c9c10864206332ed50550ba2106d94 /sapi/cli/php_cli_server.c
parent56b2a49648ea73bed4186c93a1dbf12059aa78ba (diff)
downloadphp-git-f33c7b3e41bda272de83bcc4959b3e0b968e3124.tar.gz
Added mandatory Date: header to built-in webserver
Diffstat (limited to 'sapi/cli/php_cli_server.c')
-rw-r--r--sapi/cli/php_cli_server.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index f94ac74741..e7c9f43cb4 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"
@@ -348,6 +349,13 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
smart_str_appendl_ex(buffer, "\r\n", 2, persistent);
}
}
+ 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);
} /* }}} */