aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 8b176fe..d6a69d1 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -15,6 +15,7 @@
-module(gun_http).
-export([check_options/1]).
+-export([name/0]).
-export([init/4]).
-export([handle/2]).
-export([close/1]).
@@ -23,6 +24,7 @@
-export([request/8]).
-export([data/4]).
-export([cancel/2]).
+-export([down/1]).
-export([ws_upgrade/7]).
-type io() :: head | {body, non_neg_integer()} | body_close | body_chunked.
@@ -52,6 +54,8 @@ do_check_options([{version, V}|Opts]) when V =:= 'HTTP/1.1'; V =:= 'HTTP/1.0' ->
do_check_options([Opt|_]) ->
{error, {options, {http, Opt}}}.
+name() -> http.
+
init(Owner, Socket, Transport, Opts) ->
Version = maps:get(version, Opts, 'HTTP/1.1'),
#http_state{owner=Owner, socket=Socket, transport=Transport, version=Version}.
@@ -286,6 +290,14 @@ cancel(State, StreamRef) ->
error_stream_not_found(State)
end.
+%% HTTP does not provide any way to figure out what streams are unprocessed.
+down(#http_state{streams=Streams}) ->
+ KilledStreams = [case Ref of
+ {websocket, Ref2, _, _, _} -> Ref2;
+ _ -> Ref
+ end || {Ref, _} <- Streams],
+ {KilledStreams, []}.
+
error_stream_closed(State=#http_state{owner=Owner}) ->
Owner ! {gun_error, self(), {badstate,
"The stream has already been closed."}},