aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-06-24 05:59:55 +0200
committerPřemysl Janouch <p@janouch.name>2018-06-24 06:12:16 +0200
commitdf340c13ed99bead31c54bbac003b06af82e7dd1 (patch)
tree714c816ac2c93c4d88210b046879d9cf13e397d2
parent8e986a604031aa6fce636a5e1cbb7b1933375406 (diff)
downloadjson-rpc-shell-df340c13ed99bead31c54bbac003b06af82e7dd1.tar.gz
json-rpc-shell-df340c13ed99bead31c54bbac003b06af82e7dd1.tar.xz
json-rpc-shell-df340c13ed99bead31c54bbac003b06af82e7dd1.zip
Add the missing Date header
-rw-r--r--demo-json-rpc-server.c13
1 files changed, 13 insertions, 0 deletions
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);