aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-09-14 10:08:37 +0200
committerLoïc Hoguin <[email protected]>2019-09-14 10:08:37 +0200
commit1d2904588c142800f572b02f1e9d6ac5a65caa51 (patch)
treee5929a5c59e1994030428611fabbb71d89b7b415
parent6baeb05bdbf0254c877cb9b9b8429e6bb1a98d44 (diff)
downloadcowlib-1d2904588c142800f572b02f1e9d6ac5a65caa51.tar.gz
cowlib-1d2904588c142800f572b02f1e9d6ac5a65caa51.tar.bz2
cowlib-1d2904588c142800f572b02f1e9d6ac5a65caa51.zip
Add cow_http2_machine:get_stream_local_buffer_size/2
-rw-r--r--src/cow_http2_machine.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl
index 4cda558..41605ef 100644
--- a/src/cow_http2_machine.erl
+++ b/src/cow_http2_machine.erl
@@ -31,6 +31,7 @@
-export([reset_stream/2]).
-export([get_local_setting/2]).
-export([get_last_streamid/1]).
+-export([get_stream_local_buffer_size/2]).
-export([get_stream_local_state/2]).
-export([get_stream_remote_state/2]).
@@ -1435,6 +1436,22 @@ default_setting_value(enable_connect_protocol) -> false.
get_last_streamid(#http2_machine{remote_streamid=RemoteStreamID}) ->
RemoteStreamID.
+%% Retrieve the local buffer size for a stream.
+
+-spec get_stream_local_buffer_size(cow_http2:streamid(), http2_machine())
+ -> {ok, non_neg_integer()} | {error, not_found | closed}.
+get_stream_local_buffer_size(StreamID, State=#http2_machine{mode=Mode,
+ local_streamid=LocalStreamID, remote_streamid=RemoteStreamID}) ->
+ case stream_get(StreamID, State) of
+ #stream{local_buffer_size=Size} ->
+ {ok, Size};
+ undefined when (?IS_LOCAL(Mode, StreamID) andalso (StreamID < LocalStreamID))
+ orelse ((not ?IS_LOCAL(Mode, StreamID)) andalso (StreamID =< RemoteStreamID)) ->
+ {error, closed};
+ undefined ->
+ {error, not_found}
+ end.
+
%% Retrieve the local state for a stream, including the state in the queue.
-spec get_stream_local_state(cow_http2:streamid(), http2_machine())