Skip to content

Commit

Permalink
Calculate the content-length correctly
Browse files Browse the repository at this point in the history
`lists:flatlength/1` does not return the correct size if the iolist
has binaries.  Use `erlang:iolist_size/1` instead.
e.g.

```
lists:flatlength([<<"a">>, [<<"bc">>]]).
2

erlang:iolist_size([<<"a">>, [<<"bc">>]]).
3
```
  • Loading branch information
jgmchan committed Dec 3, 2021
1 parent c6d74d7 commit d129d79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/erlazure_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ construct_url(ReqContext = #req_context{}) ->
lists:foldl(FoldFun, "", ReqContext#req_context.parameters).

get_content_length(Content) when is_list(Content) ->
lists:flatlength(Content);
erlang:iolist_size(Content);

get_content_length(Content) when is_binary(Content) ->
byte_size(Content).
byte_size(Content).

0 comments on commit d129d79

Please sign in to comment.