diff options
author | Viktor Söderqvist <[email protected]> | 2023-05-11 15:46:41 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2025-02-25 15:44:35 +0100 |
commit | 96d8e29908747ed032433f8edbcd218c7556a462 (patch) | |
tree | 31eb99faf5d18413f48f65713d8411df1c6f9799 | |
parent | 3f3ab8145ab8755527c5da30c2971dff91593e61 (diff) | |
download | gun-96d8e29908747ed032433f8edbcd218c7556a462.tar.gz gun-96d8e29908747ed032433f8edbcd218c7556a462.tar.bz2 gun-96d8e29908747ed032433f8edbcd218c7556a462.zip |
Send NO_ERROR in client-initiated graceful shutdown
-rw-r--r-- | src/gun_http2.erl | 1 | ||||
-rw-r--r-- | test/rfc7540_SUITE.erl | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl index 4903258..9b6353d 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -900,6 +900,7 @@ closing(Reason0, State=#http2_state{socket=Socket, transport=Transport, Reason = case Reason0 of normal -> no_error; owner_down -> no_error; + shutdown -> no_error; _ -> internal_error end, case Transport:send(Socket, cow_http2:goaway( diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl index 79ae347..5e72398 100644 --- a/test/rfc7540_SUITE.erl +++ b/test/rfc7540_SUITE.erl @@ -437,6 +437,22 @@ settings_ack_timeout(_) -> timer:sleep(6000), gun:close(ConnPid). +graceful_shutdown_goaway_no_error(_) -> + doc("The NO_ERROR code must be used when initiating a graceful " + "shutdown (RFC7540 6.8, RFC7540 7)"), + {ok, _, Port} = init_origin(tcp, http2, fun(Parent, _ListenSocket, Socket, _Transport) -> + %% Expect a GOAWAY with reason NO_ERROR. + {ok, <<_:24, 7:8, 0:8, 0:1, 0:31, + 0:1, 0:31, %% LastStreamID. + 0:32 %% NO_ERROR. + >>} = gen_tcp:recv(Socket, 17, 500), + Parent ! done + end), + {ok, ConnPid} = gun:open("localhost", Port, #{protocols => [http2]}), + {ok, http2} = gun:await_up(ConnPid), + gun:shutdown(ConnPid), + receive done -> ok end. + keepalive_tolerance_ping_ack_timeout(_) -> doc("The PING frame may be used to easily test a connection. (RFC7540 8.1.4)"), {ok, OriginPid, OriginPort} = init_origin(tcp, http2, do_ping_ack_loop_fun()), |