aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_tcp_proxy.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-09-18 17:01:25 +0200
committerLoïc Hoguin <[email protected]>2020-09-21 15:52:26 +0200
commit8033850ab81ca0639489636bb8760d93900d4a80 (patch)
tree94c2df630a4c6fce97f6192a63a663a25f43266c /src/gun_tcp_proxy.erl
parente740356b5881c39a95715d6081689802edf469a0 (diff)
downloadgun-8033850ab81ca0639489636bb8760d93900d4a80.tar.gz
gun-8033850ab81ca0639489636bb8760d93900d4a80.tar.bz2
gun-8033850ab81ca0639489636bb8760d93900d4a80.zip
Initial success for h2 CONNECT -> https CONNECT -> https
Diffstat (limited to 'src/gun_tcp_proxy.erl')
-rw-r--r--src/gun_tcp_proxy.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gun_tcp_proxy.erl b/src/gun_tcp_proxy.erl
index b4236f4..0107ac1 100644
--- a/src/gun_tcp_proxy.erl
+++ b/src/gun_tcp_proxy.erl
@@ -24,8 +24,14 @@
-export([close/1]).
-type socket() :: #{
+ %% The pid of the Gun connection.
+ gun_pid := pid(),
+
+ %% The pid of the process that gets replies for this tunnel.
reply_to := pid(),
- stream_ref := reference() | [reference()]
+
+ %% The full stream reference for this tunnel.
+ stream_ref := gun:stream_ref()
}.
name() -> tcp_proxy.
@@ -41,10 +47,17 @@ connect(_, _, _, _) ->
error(not_implemented).
-spec send(socket(), iodata()) -> ok.
+send(#{gun_pid := GunPid, reply_to := ReplyTo, stream_ref := StreamRef,
+ handle_continue_stream_ref := ContinueStreamRef}, Data) ->
+ GunPid ! {handle_continue, ContinueStreamRef, {data, ReplyTo, StreamRef, nofin, Data}},
+ ok;
send(#{reply_to := ReplyTo, stream_ref := StreamRef}, Data) ->
gen_statem:cast(self(), {data, ReplyTo, StreamRef, nofin, Data}).
-spec setopts(_, _) -> no_return().
+setopts(#{handle_continue_stream_ref := _}, _) ->
+ %% We send messages automatically regardless of active mode.
+ ok;
setopts(_, _) ->
error(not_implemented).