From 6612610964cabadfcf408e4223a702555a3570cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 9 Jan 2019 18:12:51 +0100 Subject: Add function gun:stream_info/2 --- src/gun_http.erl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gun_http.erl') 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 -- cgit v1.2.3