From 95006c3291fb4e359b09cd9b3986ba425484c9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 14 May 2011 15:20:12 +0200 Subject: Add the required Date header in the HTTP replies. The formatted date is generated and kept up to date regularly by a gen_server process storing it in the cowboy_clock ets table. Then it is retrieved by other processes simply by reading the table. --- src/cowboy_http_req.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/cowboy_http_req.erl') diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index 60f0b55..0956022 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -187,7 +187,8 @@ reply(Code, Headers, Body, Req=#http_req{socket=Socket, Head = response_head(Code, Headers, [ {<<"Connection">>, atom_to_connection(Connection)}, {<<"Content-Length">>, - list_to_binary(integer_to_list(iolist_size(Body)))} + list_to_binary(integer_to_list(iolist_size(Body)))}, + {<<"Date">>, cowboy_clock:rfc1123()} ]), Transport:send(Socket, [Head, Body]), {ok, Req#http_req{resp_state=done}}. @@ -198,7 +199,8 @@ chunked_reply(Code, Headers, Req=#http_req{socket=Socket, transport=Transport, resp_state=waiting}) -> Head = response_head(Code, Headers, [ {<<"Connection">>, <<"close">>}, - {<<"Transfer-Encoding">>, <<"chunked">>} + {<<"Transfer-Encoding">>, <<"chunked">>}, + {<<"Date">>, cowboy_clock:rfc1123()} ]), Transport:send(Socket, Head), {ok, Req#http_req{resp_state=chunks}}. -- cgit v1.2.3