From bd91a3207f4376bd63a72f6c5b1ebabb11747634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 5 Jan 2019 16:21:53 +0100 Subject: 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. --- src/gun.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gun.erl') 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. -- cgit v1.2.3