From 5a175dc6d5c0beddb78900b2d4ad817c9be7c2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 8 Mar 2022 15:24:23 +0100 Subject: Add a test for HTTP/2 empty DATA frame with fin set --- test/gun_SUITE.erl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl index ad39317..00b8eab 100644 --- a/test/gun_SUITE.erl +++ b/test/gun_SUITE.erl @@ -143,6 +143,29 @@ ignore_empty_data_http2(_) -> >> = Data, gun:close(Pid). +ignore_empty_data_fin_http2(_) -> + doc("When gun:data/4 is called with fin and empty data, it must send a final empty DATA frame."), + {ok, OriginPid, OriginPort} = init_origin(tcp, http2), + {ok, Pid} = gun:open("localhost", OriginPort, #{protocols => [http2]}), + {ok, http2} = gun:await_up(Pid), + handshake_completed = receive_from(OriginPid), + Ref = gun:put(Pid, "/", []), + gun:data(Pid, Ref, nofin, "hello "), + gun:data(Pid, Ref, nofin, "world!"), + gun:data(Pid, Ref, fin, ["", <<>>]), + Data = receive_all_from(OriginPid, 500), + << + %% HEADERS frame. + Len1:24, 1, _:40, _:Len1/unit:8, + %% First DATA frame. + 6:24, 0, _:7, 0:1, _:32, "hello ", + %% Second DATA frame. + 6:24, 0, _:7, 0:1, _:32, "world!", + %% Final empty DATA frame. + 0:24, 0, _:7, 1:1, _:32 + >> = Data, + gun:close(Pid). + info(_) -> doc("Get info from the Gun connection."), {ok, ListenSocket} = gen_tcp:listen(0, [binary, {active, false}]), -- cgit v1.2.3