aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-10-10 17:06:04 +0200
committerLoïc Hoguin <[email protected]>2019-10-10 17:06:04 +0200
commitc6553f8308a2ca5dcd69d845f0a7d098c40c3363 (patch)
treee9634088ff5219014a6adbaf62082c48a1119c38
parentf184de86c1583587c4ceafcc39d9960afba518e0 (diff)
downloadcowlib-c6553f8308a2ca5dcd69d845f0a7d098c40c3363.tar.gz
cowlib-c6553f8308a2ca5dcd69d845f0a7d098c40c3363.tar.bz2
cowlib-c6553f8308a2ca5dcd69d845f0a7d098c40c3363.zip
Add cow_http2_machine:is_lingering_stream/22.8.0
-rw-r--r--src/cow_http2_machine.erl11
1 files changed, 11 insertions, 0 deletions
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}) ->