aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-01-05 16:21:53 +0100
committerLoïc Hoguin <[email protected]>2019-01-05 16:21:53 +0100
commitbd91a3207f4376bd63a72f6c5b1ebabb11747634 (patch)
tree188a70e158c54941f752b3cee8606ba6ea31d939 /src/gun.erl
parent4bd87ba7d1699fc1b2901cd61b703429f1deff63 (diff)
downloadgun-bd91a3207f4376bd63a72f6c5b1ebabb11747634.tar.gz
gun-bd91a3207f4376bd63a72f6c5b1ebabb11747634.tar.bz2
gun-bd91a3207f4376bd63a72f6c5b1ebabb11747634.zip
Don't send empty data chunks
This was a bug in the case of HTTP/1.1 and an inconvenience in the case of HTTP/2.
Diffstat (limited to 'src/gun.erl')
-rw-r--r--src/gun.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gun.erl b/src/gun.erl
index a8b76f8..55e70dd 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -436,7 +436,12 @@ request(ServerPid, Method, Path, Headers, Body, ReqOpts) ->
-spec data(pid(), reference(), fin | nofin, iodata()) -> ok.
data(ServerPid, StreamRef, IsFin, Data) ->
- gen_statem:cast(ServerPid, {data, self(), StreamRef, IsFin, Data}).
+ case iolist_size(Data) of
+ 0 when IsFin =:= nofin ->
+ ok;
+ _ ->
+ gen_statem:cast(ServerPid, {data, self(), StreamRef, IsFin, Data})
+ end.
%% Tunneling.