aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-10-03 19:03:22 +0200
committerLoïc Hoguin <[email protected]>2020-10-03 19:03:22 +0200
commit37bf8c409ae341fdebdc062a33cd7fce7ac1f5b5 (patch)
treec980ff2e91a18671ba0ba8d2853e21ce77932f8a /src/gun_http.erl
parent2f42047d6cec210186d703e31e5fd970b1ea4e33 (diff)
downloadgun-37bf8c409ae341fdebdc062a33cd7fce7ac1f5b5.tar.gz
gun-37bf8c409ae341fdebdc062a33cd7fce7ac1f5b5.tar.bz2
gun-37bf8c409ae341fdebdc062a33cd7fce7ac1f5b5.zip
Fix test suites failing due to previous breaking changes
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index d2a758b..e2c0f1d 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -540,13 +540,11 @@ keepalive(State=#http_state{socket=Socket, transport=Transport, out=head}, _, Ev
keepalive(State, _, EvHandlerState) ->
{State, EvHandlerState}.
-headers(State, StreamRef, ReplyTo, Method, Host, Port,
- Path, Headers, InitialFlow, EvHandler, EvHandlerState)
+headers(State, StreamRef, ReplyTo, _, _, _, _, _, _, _, EvHandlerState)
when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- headers(State, lists:last(StreamRef), ReplyTo, Method, Host, Port,
- Path, Headers, InitialFlow, EvHandler, EvHandlerState);
+ ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef),
+ {badstate, "The stream is not a tunnel."}},
+ {State, EvHandlerState};
headers(State=#http_state{opts=Opts, out=head},
StreamRef, ReplyTo, Method, Host, Port, Path, Headers,
InitialFlow0, EvHandler, EvHandlerState0) ->
@@ -557,14 +555,11 @@ headers(State=#http_state{opts=Opts, out=head},
{new_stream(State#http_state{connection=Conn, out=Out}, StreamRef, ReplyTo,
Method, Authority, Path, InitialFlow), EvHandlerState}.
-%% @todo I don't think this clause is hit anymore. Same in other related callbacks.
-request(State, StreamRef, ReplyTo, Method, Host, Port,
- Path, Headers, Body, InitialFlow, EvHandler, EvHandlerState)
+request(State, StreamRef, ReplyTo, _, _, _, _, _, _, _, _, EvHandlerState)
when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- request(State, lists:last(StreamRef), ReplyTo, Method, Host, Port,
- Path, Headers, Body, InitialFlow, EvHandler, EvHandlerState);
+ ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef),
+ {badstate, "The stream is not a tunnel."}},
+ {State, EvHandlerState};
request(State=#http_state{opts=Opts, out=head}, StreamRef, ReplyTo,
Method, Host, Port, Path, Headers, Body,
InitialFlow0, EvHandler, EvHandlerState0) ->
@@ -652,11 +647,6 @@ transform_header_names(#http_state{opts=Opts}, Headers) ->
Fun -> lists:keymap(Fun, 1, Headers)
end.
-data(State, StreamRef, ReplyTo, IsFin, Data, EvHandler, EvHandlerState)
- when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- data(State, lists:last(StreamRef), ReplyTo, IsFin, Data, EvHandler, EvHandlerState);
%% We are expecting a new stream.
data(State=#http_state{out=head}, StreamRef, ReplyTo, _, _, _, EvHandlerState) ->
{error_stream_closed(State, StreamRef, ReplyTo), EvHandlerState};
@@ -712,11 +702,11 @@ data(State=#http_state{socket=Socket, transport=Transport, version=Version,
{error_stream_not_found(State, StreamRef, ReplyTo), EvHandlerState0}
end.
-connect(State, StreamRef, ReplyTo, Destination, TunnelInfo, Headers, InitialFlow)
+connect(State, StreamRef, ReplyTo, _, _, _, _)
when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- connect(State, lists:last(StreamRef), ReplyTo, Destination, TunnelInfo, Headers, InitialFlow);
+ ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef),
+ {badstate, "The stream is not a tunnel."}},
+ State;
connect(State=#http_state{streams=Streams}, StreamRef, ReplyTo, _, _, _, _) when Streams =/= [] ->
ReplyTo ! {gun_error, self(), stream_ref(State, StreamRef), {badstate,
"CONNECT can only be used with HTTP/1.1 when no other streams are active."}},
@@ -753,11 +743,6 @@ connect(State=#http_state{socket=Socket, transport=Transport, opts=Opts, version
new_stream(State, {connect, StreamRef, Destination}, ReplyTo,
<<"CONNECT">>, Authority, <<>>, InitialFlow).
-cancel(State, StreamRef, ReplyTo, EvHandler, EvHandlerState)
- when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- cancel(State, lists:last(StreamRef), ReplyTo, EvHandler, EvHandlerState);
%% We can't cancel anything, we can just stop forwarding messages to the owner.
cancel(State0, StreamRef, ReplyTo, EvHandler, EvHandlerState0) ->
case is_stream(State0, StreamRef) of
@@ -774,11 +759,6 @@ cancel(State0, StreamRef, ReplyTo, EvHandler, EvHandlerState0) ->
{error_stream_not_found(State0, StreamRef, ReplyTo), EvHandlerState0}
end.
-stream_info(State, StreamRef)
- when is_list(StreamRef) ->
- %% Because we switch protocol we may receive a StreamRef as a list.
- %% But we are always the final StreamRef as HTTP/1.1.
- stream_info(State, lists:last(StreamRef));
stream_info(#http_state{streams=Streams}, StreamRef) ->
case lists:keyfind(StreamRef, #stream.ref, Streams) of
#stream{reply_to=ReplyTo, is_alive=IsAlive} ->