diff options
author | Loïc Hoguin <[email protected]> | 2020-02-10 09:48:14 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-02-10 09:48:14 +0100 |
commit | 1b7b5ca356609574dac30dbec846dbd75718624e (patch) | |
tree | 51055238f2621f79b7520034b642a8a91e484255 /src | |
parent | bd6425ab87428cf4c95f4d23e0a48fd065fbd714 (diff) | |
download | gun-1b7b5ca356609574dac30dbec846dbd75718624e.tar.gz gun-1b7b5ca356609574dac30dbec846dbd75718624e.tar.bz2 gun-1b7b5ca356609574dac30dbec846dbd75718624e.zip |
Handle cow_http2_machine timeouts
Diffstat (limited to 'src')
-rw-r--r-- | src/gun.erl | 4 | ||||
-rw-r--r-- | src/gun_http2.erl | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gun.erl b/src/gun.erl index 507eef7..b08057f 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -1224,6 +1224,10 @@ handle_common_connected(cast, {data, ReplyTo, StreamRef, IsFin, Data}, _, {ProtoState2, EvHandlerState} = Protocol:data(ProtoState, StreamRef, ReplyTo, IsFin, Data, EvHandler, EvHandlerState0), {keep_state, State#state{protocol_state=ProtoState2, event_handler_state=EvHandlerState}}; +handle_common_connected(info, {timeout, TRef, Name}, _, + State=#state{protocol=Protocol, protocol_state=ProtoState}) -> + Commands = Protocol:timeout(ProtoState, Name, TRef), + commands(Commands, State); handle_common_connected(Type, Event, StateName, StateData) -> handle_common_connected_no_input(Type, Event, StateName, StateData). diff --git a/src/gun_http2.erl b/src/gun_http2.erl index 8746b3e..b0397f0 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -30,6 +30,7 @@ -export([request/12]). -export([data/7]). -export([cancel/5]). +-export([timeout/3]). -export([stream_info/2]). -export([down/1]). @@ -709,6 +710,14 @@ cancel(State=#http2_state{socket=Socket, transport=Transport, http2_machine=HTTP EvHandlerState0} end. +timeout(State=#http2_state{http2_machine=HTTP2Machine0}, {cow_http2_machine, Name}, TRef) -> + case cow_http2_machine:timeout(Name, TRef, HTTP2Machine0) of + {ok, HTTP2Machine} -> + {state, State#http2_state{http2_machine=HTTP2Machine}}; + {error, Error={connection_error, _, _}, _HTTP2Machine} -> + connection_error(State, Error) + end. + stream_info(State, StreamRef) -> case get_stream_by_ref(State, StreamRef) of #stream{reply_to=ReplyTo} -> |