aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-05-14 15:20:12 +0200
committerLoïc Hoguin <[email protected]>2011-05-14 15:20:12 +0200
commit95006c3291fb4e359b09cd9b3986ba425484c9e9 (patch)
tree10206f82aa8101ce5482b79797e1c8f96a8e0b1c /src/cowboy_http_req.erl
parent5d698250b228229001ca9966a390bf1545fcd0b0 (diff)
downloadcowboy-95006c3291fb4e359b09cd9b3986ba425484c9e9.tar.gz
cowboy-95006c3291fb4e359b09cd9b3986ba425484c9e9.tar.bz2
cowboy-95006c3291fb4e359b09cd9b3986ba425484c9e9.zip
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.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl6
1 files changed, 4 insertions, 2 deletions
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}}.