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

Handle identity transfer-encoding when determining body length

This commit is contained in:
Loïc Hoguin 2013-03-05 14:08:44 +01:00
parent 7d13391d39
commit 55e98f4f61

View file

@ -579,12 +579,12 @@ has_body(Req) ->
%% and the body hasn't been read at the time of the call. %% and the body hasn't been read at the time of the call.
-spec body_length(Req) -> {undefined | non_neg_integer(), Req} when Req::req(). -spec body_length(Req) -> {undefined | non_neg_integer(), Req} when Req::req().
body_length(Req) -> body_length(Req) ->
case lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers) of case parse_header(<<"transfer-encoding">>, Req) of
true -> {ok, [<<"identity">>], Req2} ->
{undefined, Req}; {ok, Length, Req3} = parse_header(<<"content-length">>, Req2, 0),
false -> {Length, Req3};
{ok, Length, Req2} = parse_header(<<"content-length">>, Req, 0), {ok, _, Req2} ->
{Length, Req2} {undefined, Req2}
end. end.
%% @doc Initialize body streaming and set custom decoding functions. %% @doc Initialize body streaming and set custom decoding functions.