From 5378bea9c2dd5c41796e07e38caf23a5fb09f468 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Tue, 7 Jul 2015 12:57:47 +0200 Subject: [PATCH 1/2] Use erlang:byte_size/1 for size of binaries --- src/hackney_client/hackney_request.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hackney_client/hackney_request.erl b/src/hackney_client/hackney_request.erl index a9cdb4f4..83a10bbb 100644 --- a/src/hackney_client/hackney_request.erl +++ b/src/hackney_client/hackney_request.erl @@ -341,7 +341,7 @@ handle_body(Headers, ReqType0, Body0, Client) -> <<"application/octet-stream">>), {S, CT, iolist_to_binary(Body1)}; _ when is_binary(Body0) -> - S = erlang:size(Body0), + S = erlang:byte_size(Body0), CT = hackney_headers:get_value(<<"content-type">>, Headers, <<"application/octet-stream">>), {S, CT, Body0} From c4b7e2c45bfd87806494f5e5ad3766d138edbe8e Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Tue, 7 Jul 2015 14:43:42 +0200 Subject: [PATCH 2/2] Only call iolist_to_binary once --- src/hackney_client/hackney_request.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hackney_client/hackney_request.erl b/src/hackney_client/hackney_request.erl index 83a10bbb..15e89072 100644 --- a/src/hackney_client/hackney_request.erl +++ b/src/hackney_client/hackney_request.erl @@ -336,10 +336,10 @@ handle_body(Headers, ReqType0, Body0, Client) -> _ when is_list(Body0) -> % iolist case Body1 = iolist_to_binary(Body0), - S = size(Body1), + S = erlang:byte_size(Body1), CT = hackney_headers:get_value(<<"content-type">>, Headers, <<"application/octet-stream">>), - {S, CT, iolist_to_binary(Body1)}; + {S, CT, Body1}; _ when is_binary(Body0) -> S = erlang:byte_size(Body0), CT = hackney_headers:get_value(<<"content-type">>, Headers,