From df340c13ed99bead31c54bbac003b06af82e7dd1 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Sun, 24 Jun 2018 05:59:55 +0200 Subject: Add the missing Date header --- demo-json-rpc-server.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index 0cfb13b..cf4d374 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -925,6 +925,19 @@ ws_handler_http_responsev (struct ws_handler *self, while (*fields) str_append_printf (&response, "%s\r\n", *fields++); + time_t now = time (NULL); + struct tm ts; + gmtime_r (&now, &ts); + + // See RFC 7231, 7.1.1.2. Date + const char *dow[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + const char *moy[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + str_append_printf (&response, + "Date: %s, %02d %s %04d %02d:%02d:%02d GMT\r\n", + dow[ts.tm_wday], ts.tm_mday, moy[ts.tm_mon], ts.tm_year + 1900, + ts.tm_hour, ts.tm_min, ts.tm_sec); + str_append (&response, "Server: " PROGRAM_NAME "/" PROGRAM_VERSION "\r\n\r\n"); self->write_cb (self->user_data, response.str, response.len); -- cgit v1.2.3-70-g09d2