diff options
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r-- | src/cowboy_http_req.erl | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index 60f0b55..44286e2 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -17,8 +17,8 @@ -export([ method/1, version/1, peer/1, - host/1, raw_host/1, port/1, - path/1, raw_path/1, + host/1, host_info/1, raw_host/1, port/1, + path/1, path_info/1, raw_path/1, qs_val/2, qs_val/3, qs_vals/1, raw_qs/1, binding/2, binding/3, bindings/1, header/2, header/3, headers/1 @@ -59,6 +59,12 @@ peer(Req) -> host(Req) -> {Req#http_req.host, Req}. +-spec host_info(Req::#http_req{}) + -> {HostInfo::cowboy_dispatcher:path_tokens() | undefined, + Req::#http_req{}}. +host_info(Req) -> + {Req#http_req.host_info, Req}. + -spec raw_host(Req::#http_req{}) -> {RawHost::binary(), Req::#http_req{}}. raw_host(Req) -> {Req#http_req.raw_host, Req}. @@ -72,6 +78,12 @@ port(Req) -> path(Req) -> {Req#http_req.path, Req}. +-spec path_info(Req::#http_req{}) + -> {PathInfo::cowboy_dispatcher:path_tokens() | undefined, + Req::#http_req{}}. +path_info(Req) -> + {Req#http_req.path_info, Req}. + -spec raw_path(Req::#http_req{}) -> {RawPath::binary(), Req::#http_req{}}. raw_path(Req) -> {Req#http_req.raw_path, Req}. @@ -187,7 +199,9 @@ 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()}, + {<<"Server">>, <<"Cowboy">>} ]), Transport:send(Socket, [Head, Body]), {ok, Req#http_req{resp_state=done}}. @@ -198,7 +212,9 @@ 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()}, + {<<"Server">>, <<"Cowboy">>} ]), Transport:send(Socket, Head), {ok, Req#http_req{resp_state=chunks}}. |