mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Merge branch 'has_body_improved' of git://github.com/0xAX/cowboy
This commit is contained in:
commit
1df271a35b
1 changed files with 8 additions and 2 deletions
|
@ -564,8 +564,14 @@ set_meta(Name, Value, Req=#http_req{meta=Meta}) ->
|
|||
%% @doc Return whether the request message has a body.
|
||||
-spec has_body(cowboy_req:req()) -> boolean().
|
||||
has_body(Req) ->
|
||||
lists:keymember(<<"content-length">>, 1, Req#http_req.headers) orelse
|
||||
lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers).
|
||||
case lists:keyfind(<<"content-length">>, 1, Req#http_req.headers) of
|
||||
{_, <<"0">>} ->
|
||||
false;
|
||||
{_, _} ->
|
||||
true;
|
||||
_ ->
|
||||
lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers)
|
||||
end.
|
||||
|
||||
%% @doc Return the request message body length, if known.
|
||||
%%
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue