From c6553f8308a2ca5dcd69d845f0a7d098c40c3363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 10 Oct 2019 17:06:04 +0200 Subject: Add cow_http2_machine:is_lingering_stream/2 --- src/cow_http2_machine.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl index 754b82b..30654d0 100644 --- a/src/cow_http2_machine.erl +++ b/src/cow_http2_machine.erl @@ -35,6 +35,7 @@ -export([get_stream_local_buffer_size/2]). -export([get_stream_local_state/2]). -export([get_stream_remote_state/2]). +-export([is_lingering_stream/2]). -type opts() :: #{ connection_window_margin_size => 0..16#7fffffff, @@ -1550,6 +1551,16 @@ get_stream_remote_state(StreamID, State=#http2_machine{mode=Mode, {error, not_found} end. +%% Query whether the stream was reset recently by the remote endpoint. + +-spec is_lingering_stream(cow_http2:streamid(), http2_machine()) -> boolean(). +is_lingering_stream(StreamID, #http2_machine{ + local_lingering_streams=Local, remote_lingering_streams=Remote}) -> + case lists:member(StreamID, Local) of + true -> true; + false -> lists:member(StreamID, Remote) + end. + %% Stream-related functions. stream_get(StreamID, #http2_machine{streams=Streams}) -> -- cgit v1.2.3