aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http2.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-09-21 12:18:03 +0200
committerLoïc Hoguin <[email protected]>2020-09-21 15:52:26 +0200
commit43df59e49b1ab92e3ca0a333ae403742b2ed7a5d (patch)
treec0903c6588ab829109e9cd79bb6b2652d2fd34eb /src/gun_http2.erl
parent8033850ab81ca0639489636bb8760d93900d4a80 (diff)
downloadgun-43df59e49b1ab92e3ca0a333ae403742b2ed7a5d.tar.gz
gun-43df59e49b1ab92e3ca0a333ae403742b2ed7a5d.tar.bz2
gun-43df59e49b1ab92e3ca0a333ae403742b2ed7a5d.zip
Fix gun:stream_info/2 when gun_tunnel is involved
Diffstat (limited to 'src/gun_http2.erl')
-rw-r--r--src/gun_http2.erl30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl
index df76195..65b92e2 100644
--- a/src/gun_http2.erl
+++ b/src/gun_http2.erl
@@ -391,7 +391,8 @@ data_frame(State0, StreamID, IsFin, Data, EvHandler, EvHandlerState0,
{maybe_delete_stream(State, StreamID, remote, IsFin), EvHandlerState}.
%% @todo Make separate functions for inform/connect/normal.
-headers_frame(State0=#http2_state{opts=Opts, content_handlers=Handlers0, commands_queue=Commands},
+headers_frame(State0=#http2_state{transport=Transport, opts=Opts,
+ content_handlers=Handlers0, commands_queue=Commands},
StreamID, IsFin, Headers, #{status := Status}, _BodyLen,
EvHandler, EvHandlerState0) ->
Stream = get_stream_by_id(State0, StreamID),
@@ -463,6 +464,8 @@ headers_frame(State0=#http2_state{opts=Opts, content_handlers=Handlers0, command
stream_ref => RealStreamRef,
tunnel => #{
type => connect,
+ transport_name => Transport:name(),
+ protocol_name => http2,
info => TunnelInfo,
handshake_event => HandshakeEvent,
protocols => Protocols
@@ -474,6 +477,8 @@ headers_frame(State0=#http2_state{opts=Opts, content_handlers=Handlers0, command
stream_ref => RealStreamRef,
tunnel => #{
type => connect,
+ transport_name => Transport:name(),
+ protocol_name => http2,
info => TunnelInfo,
new_protocol => NewProtocol
}
@@ -1062,10 +1067,9 @@ stream_info(State, StreamRef) when is_reference(StreamRef) ->
{ok, undefined}
end;
%% Tunneled streams.
-stream_info(State=#http2_state{transport=Transport}, StreamRefList=[StreamRef|Tail]) ->
+stream_info(State, StreamRefList=[StreamRef|Tail]) ->
case get_stream_by_ref(State, StreamRef) of
- #stream{tunnel=#tunnel{protocol=Proto, protocol_state=ProtoState,
- info=TunnelInfo=#{host := TunnelHost, port := TunnelPort}}} ->
+ #stream{tunnel=#tunnel{protocol=Proto, protocol_state=ProtoState}} ->
%% We must return the real StreamRef as seen by the user.
%% We therefore set it on return, with the outer layer "winning".
%%
@@ -1076,23 +1080,7 @@ stream_info(State=#http2_state{transport=Transport}, StreamRefList=[StreamRef|Ta
{ok, undefined} ->
{ok, undefined};
{ok, Info} ->
- %% @todo Double check intermediaries.
- Intermediaries1 = maps:get(intermediaries, TunnelInfo, []),
- Intermediaries2 = maps:get(intermediaries, Info, []),
- {ok, Info#{
- ref => StreamRefList,
- intermediaries => [#{
- type => connect,
- host => TunnelHost,
- port => TunnelPort,
- transport => case Transport:name() of
- tcp_proxy -> tcp;
- tls_proxy -> tls;
- TransportName -> TransportName
- end,
- protocol => http2
- }|Intermediaries1 ++ Intermediaries2]
- }}
+ {ok, Info#{ref => StreamRefList}}
end;
error ->
{ok, undefined}