aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-01-02 16:19:44 +0100
committerLoïc Hoguin <[email protected]>2017-01-02 16:19:44 +0100
commit8f8f63b1cef76a28b2bf7558f4dbb7feda6e9168 (patch)
tree5ceefbbfea36b3e53d9cf9ce537ea3522a01f20c /src/gun_http.erl
parentc747a613ec28c4835b33ffd924a390ee55f3cf03 (diff)
downloadgun-8f8f63b1cef76a28b2bf7558f4dbb7feda6e9168.tar.gz
gun-8f8f63b1cef76a28b2bf7558f4dbb7feda6e9168.tar.bz2
gun-8f8f63b1cef76a28b2bf7558f4dbb7feda6e9168.zip
Fix sending of body as iodata() with HTTP
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 46ff00a..65135f9 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -257,6 +257,7 @@ data(State=#http_state{socket=Socket, transport=Transport, version=Version,
out=Out, streams=Streams}, StreamRef, IsFin, Data) ->
case lists:last(Streams) of
{StreamRef, _, true} ->
+ DataLength = iolist_size(Data),
case Out of
body_chunked when Version =:= 'HTTP/1.1', IsFin =:= fin ->
case Data of
@@ -272,9 +273,9 @@ data(State=#http_state{socket=Socket, transport=Transport, version=Version,
body_chunked when Version =:= 'HTTP/1.1' ->
Transport:send(Socket, cow_http_te:chunk(Data)),
State;
- {body, Length} when byte_size(Data) =< Length ->
+ {body, Length} when DataLength =< Length ->
Transport:send(Socket, Data),
- Length2 = Length - byte_size(Data),
+ Length2 = Length - DataLength,
if
Length2 =:= 0, IsFin =:= fin ->
State#http_state{out=head};