aboutsummaryrefslogtreecommitdiffstats
path: root/test/raw_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-07-16 14:56:45 +0200
committerLoïc Hoguin <[email protected]>2020-09-21 15:51:46 +0200
commita093bf88e1740e4f89937d84cd4d5b26cb5b4e80 (patch)
tree513bdd79b59c74c76e0f7d8d9561521b49074941 /test/raw_SUITE.erl
parent921c47146b2d9567eac7e9a4d2ccc60fffd4f327 (diff)
downloadgun-a093bf88e1740e4f89937d84cd4d5b26cb5b4e80.tar.gz
gun-a093bf88e1740e4f89937d84cd4d5b26cb5b4e80.tar.bz2
gun-a093bf88e1740e4f89937d84cd4d5b26cb5b4e80.zip
Initial HTTP/2 CONNECT implementation
Diffstat (limited to 'test/raw_SUITE.erl')
-rw-r--r--test/raw_SUITE.erl48
1 files changed, 47 insertions, 1 deletions
diff --git a/test/raw_SUITE.erl b/test/raw_SUITE.erl
index 18ab3b5..9b836c0 100644
--- a/test/raw_SUITE.erl
+++ b/test/raw_SUITE.erl
@@ -139,7 +139,7 @@ do_connect_raw(OriginTransport, ProxyTransport) ->
protocols => [raw]
}),
{request, <<"CONNECT">>, Authority, 'HTTP/1.1', _} = receive_from(ProxyPid),
- {response, fin, 200, _} = gun:await(ConnPid, StreamRef),
+ {response, fin, 200, _} = gun:await(ConnPid, StreamRef), %% @todo Why fin?
handshake_completed = receive_from(OriginPid),
%% When we take over the entire connection there is no stream reference.
gun:data(ConnPid, undefined, nofin, <<"Hello world!">>),
@@ -186,6 +186,52 @@ connect_raw_reply_to(_) ->
gun:data(ConnPid, undefined, nofin, <<"Hello world!">>),
receive {ReplyTo, ok} -> gun:close(ConnPid) after 1000 -> error(timeout) end.
+h2_connect_tcp_raw_tcp(_) ->
+ doc("Use HTTP/2 CONNECT over TCP to connect to a remote endpoint using the raw protocol over TCP."),
+ do_h2_connect_raw(tcp, tcp).
+
+do_h2_connect_raw(OriginTransport, ProxyTransport) ->
+ {ok, OriginPid, OriginPort} = init_origin(OriginTransport, raw, fun do_echo/3),
+ {ok, ProxyPid, ProxyPort} = rfc7540_SUITE:do_proxy_start(ProxyTransport, [
+ {proxy_stream, 1, 200, [], 0, undefined}
+ ]),
+ Authority = iolist_to_binary(["localhost:", integer_to_binary(OriginPort)]),
+ {ok, ConnPid} = gun:open("localhost", ProxyPort, #{
+ transport => ProxyTransport,
+ protocols => [http2]
+ }),
+ {ok, http2} = gun:await_up(ConnPid),
+ handshake_completed = receive_from(ProxyPid),
+ StreamRef = gun:connect(ConnPid, #{
+ host => "localhost",
+ port => OriginPort,
+ transport => OriginTransport,
+ protocols => [raw]
+ }),
+ {request, #{
+ <<":method">> := <<"CONNECT">>,
+ <<":authority">> := Authority
+ }} = receive_from(ProxyPid),
+ {response, nofin, 200, _} = gun:await(ConnPid, StreamRef),
+ handshake_completed = receive_from(OriginPid),
+ gun:data(ConnPid, StreamRef, nofin, <<"Hello world!">>),
+ {data, nofin, <<"Hello world!">>} = gun:await(ConnPid, undefined),
+%% @todo
+% #{
+% transport := OriginTransport,
+% protocol := raw,
+% origin_scheme := _, %% @todo This should be 'undefined'.
+% origin_host := "localhost",
+% origin_port := OriginPort,
+% intermediaries := [#{
+% type := connect,
+% host := "localhost",
+% port := ProxyPort,
+% transport := ProxyTransport,
+% protocol := http
+% }]} = gun:info(ConnPid),
+ gun:close(ConnPid).
+
http11_upgrade_raw_tcp(_) ->
doc("Use the HTTP Upgrade mechanism to switch to the raw protocol over TCP."),
do_http11_upgrade_raw(tcp).