From 3d1e3c9e6e779bca839b86717adb2487b4a1c2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 24 Jul 2019 16:22:26 +0200 Subject: Add the cancel event for local/remote stream cancellation --- src/gun_event.erl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/gun_event.erl') diff --git a/src/gun_event.erl b/src/gun_event.erl index f27d336..c87af58 100644 --- a/src/gun_event.erl +++ b/src/gun_event.erl @@ -236,6 +236,25 @@ -callback ws_send_frame_start(ws_send_frame_event(), State) -> State. -callback ws_send_frame_end(ws_send_frame_event(), State) -> State. +%% cancel. +%% +%% In the case of HTTP/1.1 we cannot actually cancel the stream, +%% we only silence the stream to the user. Further response events +%% may therefore be received and they provide a useful metric as +%% these canceled requests monopolize the connection. +%% +%% For HTTP/2 both the client and the server may cancel streams. +%% Events may still occur for a short time after the cancel. + +-type cancel_event() :: #{ + stream_ref := reference(), + reply_to := pid(), + endpoint := local | remote, + reason := atom() +}. + +-callback cancel(cancel_event(), State) -> State. + %% disconnect. -type disconnect_event() :: #{ @@ -255,5 +274,3 @@ %% @todo origin_changed %% @todo transport_changed -%% @todo cancel_start -%% @todo cancel_end -- cgit v1.2.3