Skip to content

Commit

Permalink
pass the buffer form the parser to the client on HEAD and Clen=0
Browse files Browse the repository at this point in the history
By doing this we make sure to handle pipelines requests in the future.
  • Loading branch information
benoitc committed Dec 19, 2013
1 parent 987178e commit db99d5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ Alexey Aniskin <[email protected]>
Yuki Ito <[email protected]>
Yuriy Bogdanov <[email protected]>
Ben Murphy <[email protected]>
Richard Jones <[email protected]>
13 changes: 8 additions & 5 deletions src/hackney_response.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down

0 comments on commit db99d5e

Please sign in to comment.