0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

cowbot_req:has_body:/1 improved

This commit is contained in:
0xAX 2013-02-14 18:56:52 +06:00
parent 46cce48143
commit 1de2e1f2a4

View file

@ -564,8 +564,14 @@ set_meta(Name, Value, Req=#http_req{meta=Meta}) ->
%% @doc Return whether the request message has a body. %% @doc Return whether the request message has a body.
-spec has_body(cowboy_req:req()) -> boolean(). -spec has_body(cowboy_req:req()) -> boolean().
has_body(Req) -> has_body(Req) ->
lists:keymember(<<"content-length">>, 1, Req#http_req.headers) orelse case lists:keyfind(<<"content-length">>, 1, Req#http_req.headers) of
lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers). {_, <<"0">>} ->
false;
{_, _} ->
true;
_ ->
lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers)
end.
%% @doc Return the request message body length, if known. %% @doc Return the request message body length, if known.
%% %%