From 1ee2a1913e79e010733991d8373b2517abf0d91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bj=C3=B6rklund?= Date: Mon, 19 Apr 2021 20:03:57 +0200 Subject: Handle any zero-sized Data in http:data with fin Amended to make the test case hit the problem. --- test/gun_SUITE.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl index 1a15b01..ad39317 100644 --- a/test/gun_SUITE.erl +++ b/test/gun_SUITE.erl @@ -107,6 +107,21 @@ ignore_empty_data_http(_) -> 1 = length(Zero), gun:close(Pid). +ignore_empty_data_fin_http(_) -> + doc("When gun:data/4 is called with fin and empty data, it must send a final empty chunk."), + {ok, OriginPid, OriginPort} = init_origin(tcp, http), + {ok, Pid} = gun:open("localhost", OriginPort), + {ok, http} = gun:await_up(Pid), + handshake_completed = receive_from(OriginPid), + Ref = gun:post(Pid, "/", []), + gun:data(Pid, Ref, nofin, "hello"), + gun:data(Pid, Ref, fin, ["", <<>>]), + Data = receive_all_from(OriginPid, 500), + Lines = binary:split(Data, <<"\r\n">>, [global]), + Zero = [Z || <<"0">> = Z <- Lines], + 1 = length(Zero), + gun:close(Pid). + ignore_empty_data_http2(_) -> doc("When gun:data/4 is called with nofin and empty data, it must be ignored."), {ok, OriginPid, OriginPort} = init_origin(tcp, http2), -- cgit v1.2.3