aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-01-05 22:30:10 +0100
committerLoïc Hoguin <[email protected]>2019-01-05 22:30:10 +0100
commit08c4a71c801246c66427f2a37d2f0f6de561d448 (patch)
treee12b21419c277692d44834e6b867a0f5c95d07b2 /src
parentab72796fdcc30a1227cbdd9069bd36aff14ebcfc (diff)
downloadgun-08c4a71c801246c66427f2a37d2f0f6de561d448.tar.gz
gun-08c4a71c801246c66427f2a37d2f0f6de561d448.tar.bz2
gun-08c4a71c801246c66427f2a37d2f0f6de561d448.zip
Fix transfer-encoding precedence over content-length
Diffstat (limited to 'src')
-rw-r--r--src/gun_http.erl28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 164ede8..ec459a3 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -522,22 +522,20 @@ response_io_from_headers(<<"HEAD">>, _, _, _) ->
response_io_from_headers(_, _, Status, _) when (Status =:= 204) or (Status =:= 304) ->
head;
response_io_from_headers(_, Version, _Status, Headers) ->
- case lists:keyfind(<<"content-length">>, 1, Headers) of
- {_, <<"0">>} ->
- head;
- {_, Length} ->
- {body, cow_http_hd:parse_content_length(Length)};
- _ when Version =:= 'HTTP/1.0' ->
- body_close;
+ case lists:keyfind(<<"transfer-encoding">>, 1, Headers) of
+ {_, TE} when Version =:= 'HTTP/1.1' ->
+ case cow_http_hd:parse_transfer_encoding(TE) of
+ [<<"chunked">>] -> body_chunked;
+ [<<"identity">>] -> body_close
+ end;
_ ->
- case lists:keyfind(<<"transfer-encoding">>, 1, Headers) of
- false ->
- body_close;
- {_, TE} ->
- case cow_http_hd:parse_transfer_encoding(TE) of
- [<<"chunked">>] -> body_chunked;
- [<<"identity">>] -> body_close
- end
+ case lists:keyfind(<<"content-length">>, 1, Headers) of
+ {_, <<"0">>} ->
+ head;
+ {_, Length} ->
+ {body, cow_http_hd:parse_content_length(Length)};
+ _ ->
+ body_close
end
end.