Skip to content

Commit

Permalink
recv: if expected size < BufSize fallback to old behaviour
Browse files Browse the repository at this point in the history
fix #722
  • Loading branch information
benoitc committed Sep 15, 2023
1 parent abed0ae commit 42ea010
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/hackney_response.erl
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@ recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}) ->

recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {_BufSize, undefined}) ->
Transport:recv(Skt, 0, Timeout);
recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {BufSize, ExpectedSize}) ->
Transport:recv(Skt, ExpectedSize - BufSize, Timeout).
recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {BufSize, ExpectedSize}) when ExpectedSize >= BufSize ->
Transport:recv(Skt, ExpectedSize - BufSize, Timeout);
recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {_BufSize, _ExpectedSize}) ->
Transport:recv(Skt, 0, Timeout).

close(#client{socket=nil}=Client) ->
Client#client{state = closed};
Expand Down

0 comments on commit 42ea010

Please sign in to comment.