diff options
author | Loïc Hoguin <[email protected]> | 2025-03-21 13:10:50 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2025-03-21 13:10:50 +0100 |
commit | dd1a09d7c8395d8e77d40a8bc5e1e4537c3c15b3 (patch) | |
tree | 3d5b39a82b96a0f27790d4f441f69f3fec424b63 /src/gun_http.erl | |
parent | 04c3436586eb150225791f96692eeff78f4d27c1 (diff) | |
download | gun-respect-remote-concurrency-limit.tar.gz gun-respect-remote-concurrency-limit.tar.bz2 gun-respect-remote-concurrency-limit.zip |
Respect remote concurrency limit for headers/connect/ws_upgraderespect-remote-concurrency-limit
In order to simplify the implementation the CookieStore is
given to the connect function now, even though it's not
currently used.
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r-- | src/gun_http.erl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl index d4304b0..98acbc1 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -29,7 +29,7 @@ -export([headers/12]). -export([request/13]). -export([data/7]). --export([connect/9]). +-export([connect/10]). -export([cancel/5]). -export([stream_info/2]). -export([down/1]). @@ -759,19 +759,20 @@ data(State=#http_state{socket=Socket, transport=Transport, version=Version, {[], EvHandlerState0} end. -connect(State, StreamRef, ReplyTo, _, _, _, _, _, EvHandlerState) +connect(State, StreamRef, ReplyTo, _, _, _, _, CookieStore, _, EvHandlerState) when is_list(StreamRef) -> gun:reply(ReplyTo, {gun_error, self(), stream_ref(State, StreamRef), {badstate, "The stream is not a tunnel."}}), - {[], EvHandlerState}; -connect(State=#http_state{streams=Streams}, StreamRef, ReplyTo, _, _, _, _, _, EvHandlerState) + {[], CookieStore, EvHandlerState}; +connect(State=#http_state{streams=Streams}, StreamRef, ReplyTo, _, _, _, _, + CookieStore, _, EvHandlerState) when Streams =/= [] -> gun:reply(ReplyTo, {gun_error, self(), stream_ref(State, StreamRef), {badstate, "CONNECT can only be used with HTTP/1.1 when no other streams are active."}}), - {[], EvHandlerState}; + {[], CookieStore, EvHandlerState}; connect(State=#http_state{socket=Socket, transport=Transport, opts=Opts, version=Version}, StreamRef, ReplyTo, Destination=#{host := Host0}, _TunnelInfo, Headers0, InitialFlow0, - EvHandler, EvHandlerState0) -> + CookieStore, EvHandler, EvHandlerState0) -> Host = case Host0 of Tuple when is_tuple(Tuple) -> inet:ntoa(Tuple); _ -> Host0 @@ -817,9 +818,9 @@ connect(State=#http_state{socket=Socket, transport=Transport, opts=Opts, version InitialFlow = initial_flow(InitialFlow0, Opts), {{state, new_stream(State, {connect, StreamRef, Destination}, ReplyTo, <<"CONNECT">>, Authority, <<>>, InitialFlow)}, - EvHandlerState}; + CookieStore, EvHandlerState}; Error={error, _} -> - {Error, EvHandlerState1} + {Error, CookieStore, EvHandlerState1} end. %% We can't cancel anything, we can just stop forwarding messages to the owner. |