aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_raw.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-07-17 14:05:43 +0200
committerLoïc Hoguin <[email protected]>2020-09-21 15:51:56 +0200
commitd7481d5f593f48327d16c29b48a74e49c7581e0a (patch)
tree044bd6efdf33a7d1f2cafe889af5626b2c2c0d97 /src/gun_raw.erl
parent510d49d8ef0a46e90374c3230f28b5354115293f (diff)
downloadgun-d7481d5f593f48327d16c29b48a74e49c7581e0a.tar.gz
gun-d7481d5f593f48327d16c29b48a74e49c7581e0a.tar.bz2
gun-d7481d5f593f48327d16c29b48a74e49c7581e0a.zip
Improve HTTP/2 CONNECT to non-HTTP origin
Now has a proper StreamRef given to it by the CONNECT stream.
Diffstat (limited to 'src/gun_raw.erl')
-rw-r--r--src/gun_raw.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gun_raw.erl b/src/gun_raw.erl
index bef2c1c..369353e 100644
--- a/src/gun_raw.erl
+++ b/src/gun_raw.erl
@@ -26,6 +26,7 @@
%% @todo down
-record(raw_state, {
+ ref :: reference() | undefined,
reply_to :: pid(),
socket :: inet:socket() | ssl:sslsocket(),
transport :: module()
@@ -39,12 +40,13 @@ name() -> raw.
opts_name() -> raw_opts.
has_keepalive() -> false.
-init(ReplyTo, Socket, Transport, _Opts) ->
- {connected_data_only, #raw_state{reply_to=ReplyTo, socket=Socket, transport=Transport}}.
+init(ReplyTo, Socket, Transport, Opts) ->
+ StreamRef = maps:get(stream_ref, Opts, undefined),
+ {connected_data_only, #raw_state{ref=StreamRef, reply_to=ReplyTo, socket=Socket, transport=Transport}}.
-handle(Data, State=#raw_state{reply_to=ReplyTo}, _, EvHandlerState) ->
+handle(Data, State=#raw_state{ref=StreamRef, reply_to=ReplyTo}, _, EvHandlerState) ->
%% When we take over the entire connection there is no stream reference.
- ReplyTo ! {gun_data, self(), undefined, nofin, Data},
+ ReplyTo ! {gun_data, self(), StreamRef, nofin, Data},
{{state, State}, EvHandlerState}.
%% We can always close immediately.