diff options
Diffstat (limited to 'test/raw_SUITE.erl')
-rw-r--r-- | test/raw_SUITE.erl | 48 |
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). |