@@ -77,12 +77,17 @@ perform(Client0, {Method0, Path0, Headers0, Body0}) ->
77
77
Size , Boundary , Client0 );
78
78
<<>> when Method =:= <<" POST" >> orelse Method =:= <<" PUT" >> ->
79
79
handle_body (Headers2 , ReqType0 , Body0 , Client0 );
80
- [] when Method =:= <<" POST" >> orelse Method =:= <<" PUT" >> ->
81
- handle_body (Headers2 , ReqType0 , Body0 , Client0 );
82
80
<<>> ->
83
81
{Headers2 , ReqType0 , Body0 , Client0 };
84
- [] ->
85
- {Headers2 , ReqType0 , Body0 , Client0 };
82
+ _ when is_list (Body0 ) ->
83
+ case iolist_to_binary (Body0 ) of
84
+ <<>> when Method =:= <<" POST" >> orelse Method =:= <<" PUT" >> ->
85
+ handle_body (Headers2 , ReqType0 , Body0 , Client0 );
86
+ <<>> ->
87
+ {Headers2 , ReqType0 , Body0 , Client0 };
88
+ Body1 ->
89
+ handle_body (Headers2 , ReqType0 , Body1 , Client0 )
90
+ end ;
86
91
_ ->
87
92
handle_body (Headers2 , ReqType0 , Body0 , Client0 )
88
93
end ,
@@ -348,13 +353,6 @@ handle_body(Headers, ReqType0, Body0, Client) ->
348
353
S = hackney_headers_new :get_value (<<" content-length" >>, Headers ),
349
354
{S , CT , Body0 };
350
355
351
- _ when is_list (Body0 ) -> % iolist case
352
- Body1 = iolist_to_binary (Body0 ),
353
- S = erlang :byte_size (Body1 ),
354
- CT = hackney_headers_new :get_value (
355
- <<" content-type" >>, Headers , <<" application/octet-stream" >>
356
- ),
357
- {S , CT , Body1 };
358
356
_ when is_binary (Body0 ) ->
359
357
S = erlang :byte_size (Body0 ),
360
358
CT = hackney_headers_new :get_value (
0 commit comments