diff --git a/THANKS b/THANKS index 8171f5e1..a35688ee 100644 --- a/THANKS +++ b/THANKS @@ -24,3 +24,4 @@ Alexey Aniskin Yuki Ito Yuriy Bogdanov Ben Murphy +Richard Jones diff --git a/src/hackney_response.erl b/src/hackney_response.erl index 0ca9d040..f89ea48f 100644 --- a/src/hackney_response.erl +++ b/src/hackney_response.erl @@ -121,12 +121,15 @@ wait_headers({header, {Key, Value}=KV, Parser}, Client, Status, Headers) -> wait_headers({headers_complete, Parser}, Client, Status, Headers) -> {ok, Status, lists:reverse(Headers), Client#client{parser=Parser}}. -stream_body(Client=#client{response_state= done}) -> - {done, Client}; -stream_body(Client=#client{method= <<"HEAD">>}) -> - {done, Client}; -stream_body(Client=#client{clen=0, te=TE}) when TE /= <<"chunked">> -> +stream_body(Client=#client{response_state=done}) -> {done, Client}; +stream_body(Client=#client{method= <<"HEAD">>, parser=Parser}) -> + Buffer = hackney_http:get(Parser, buffer), + {done, Client#client{buffer=Buffer}}; +stream_body(Client=#client{parser=Parser, clen=0, te=TE}) + when TE /= <<"chunked">> -> + Buffer = hackney_http:get(Parser, buffer), + {done, Client#client{buffer=Buffer}}; stream_body(Client=#client{parser=Parser}) -> stream_body1(hackney_http:execute(Parser), Client).