Skip to content

Commit

Permalink
handle case where Length is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Oct 11, 2023
1 parent aa95d66 commit f8b89cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hackney_response.erl
Expand Up @@ -232,17 +232,19 @@ multipart_data(Client, Length, {mp_mixed, Cont}) ->
multipart_data(Client, Length, {mp_mixed_eof, Cont}) ->
{mp_mixed_eof, Client#client{multipart={Length, Cont}}};
multipart_data(Client, Length, eof)
when Length =:= 0 orelse Length =:= nil ->
when Length =:= 0 orelse Length =:= nil orelse Length =:= undefined ->
Client2 = end_stream_body(<<>>, Client),
{eof, Client2#client{body_state=done, multipart=nil}};
multipart_data(Client, _, eof) ->
%% We just want to skip so no need to stream data here.
{skip, Client2} = skip_body(Client),
{eof, Client2#client{multipart=nil}};
multipart_data(Client, Length, {more, Parser})
when Length > 0 orelse Length =:= nil->
when Length > 0 orelse Length =:= nil orelse Length =:= undefined ->
case stream_body(Client) of
{ok, Data, Client2} when Length =:= nil ->
{ok, Data, Client2} when Length =:= nil ->
multipart_data(Client2, Length, Parser(Data));
{ok, Data, Client2} when Length =:= undefined ->
multipart_data(Client2, Length, Parser(Data));
{ok, << Data:Length/binary, Buffer/binary >>, Client2} ->
multipart_data(Client2#client{buffer=Buffer}, 0,
Expand Down

0 comments on commit f8b89cd

Please sign in to comment.