Current section
Files
Jump to
Current section
Files
src/recv_loop.erl.OFF
recv_loop(Conn, Res, Timeout) ->
Body = maps:get(body, Res, <<>>),
case byte_size(Body) < content_length(Res) of
true ->
case recv(Conn, content_length(Res) - byte_size(Body), Timeout) of
{ok, Data} ->
recv_loop(Conn, Res#{body => <<Body/binary, Data/binary>>}, Timeout);
{error, closed} ->
{ok, Res};
Other ->
Other
end;
false ->
{ok, Res}
end.