Browse Source

Add cow_http2_machine:is_lingering_stream/2

Loïc Hoguin 5 years ago
parent
commit
816e2528c8
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/cow_http2_machine.erl

+ 11 - 0
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}) ->