diff options
author | Loïc Hoguin <[email protected]> | 2013-03-05 14:08:44 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-03-05 14:08:44 +0100 |
commit | 55e98f4f61b8a7da470bed5e1473c1a186cf8c1f (patch) | |
tree | fcb54746e9945126a472d318b4284527aab21e3a /src | |
parent | 7d13391d398bffbfe9460d094f28caf42638a454 (diff) | |
download | cowboy-55e98f4f61b8a7da470bed5e1473c1a186cf8c1f.tar.gz cowboy-55e98f4f61b8a7da470bed5e1473c1a186cf8c1f.tar.bz2 cowboy-55e98f4f61b8a7da470bed5e1473c1a186cf8c1f.zip |
Handle identity transfer-encoding when determining body length
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_req.erl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index 79aa44d..c800595 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -579,12 +579,12 @@ has_body(Req) -> %% 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(). body_length(Req) -> - case lists:keymember(<<"transfer-encoding">>, 1, Req#http_req.headers) of - true -> - {undefined, Req}; - false -> - {ok, Length, Req2} = parse_header(<<"content-length">>, Req, 0), - {Length, Req2} + case parse_header(<<"transfer-encoding">>, Req) of + {ok, [<<"identity">>], Req2} -> + {ok, Length, Req3} = parse_header(<<"content-length">>, Req2, 0), + {Length, Req3}; + {ok, _, Req2} -> + {undefined, Req2} end. %% @doc Initialize body streaming and set custom decoding functions. |