aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-01-09 18:12:51 +0100
committerLoïc Hoguin <[email protected]>2019-01-09 18:12:51 +0100
commit6612610964cabadfcf408e4223a702555a3570cb (patch)
tree98598c40aa031aba05ddbe79d5858fc573bb7b5a /src/gun_http.erl
parentab4878838fafbd453b41d031c9224b2ee8d2d956 (diff)
downloadgun-6612610964cabadfcf408e4223a702555a3570cb.tar.gz
gun-6612610964cabadfcf408e4223a702555a3570cb.tar.bz2
gun-6612610964cabadfcf408e4223a702555a3570cb.zip
Add function gun:stream_info/2
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 376f431..719307c 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -25,6 +25,7 @@
-export([data/5]).
-export([connect/5]).
-export([cancel/3]).
+-export([stream_info/2]).
-export([down/1]).
-export([ws_upgrade/7]).
@@ -473,6 +474,21 @@ cancel(State, StreamRef, ReplyTo) ->
error_stream_not_found(State, StreamRef, ReplyTo)
end.
+stream_info(#http_state{streams=Streams}, StreamRef) ->
+ case lists:keyfind(StreamRef, #stream.ref, Streams) of
+ #stream{reply_to=ReplyTo, is_alive=IsAlive} ->
+ {ok, #{
+ ref => StreamRef,
+ reply_to => ReplyTo,
+ state => case IsAlive of
+ true -> running;
+ false -> stopping
+ end
+ }};
+ false ->
+ {ok, undefined}
+ end.
+
%% HTTP does not provide any way to figure out what streams are unprocessed.
down(#http_state{streams=Streams}) ->
KilledStreams = [case Ref of