aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-07-17 12:25:11 +0200
committerLoïc Hoguin <[email protected]>2020-09-21 15:51:56 +0200
commit510d49d8ef0a46e90374c3230f28b5354115293f (patch)
tree2260d16089803e9e6e9c3e9156e21f83b0eae81c /test
parenta093bf88e1740e4f89937d84cd4d5b26cb5b4e80 (diff)
downloadgun-510d49d8ef0a46e90374c3230f28b5354115293f.tar.gz
gun-510d49d8ef0a46e90374c3230f28b5354115293f.tar.bz2
gun-510d49d8ef0a46e90374c3230f28b5354115293f.zip
Make gun:stream_info/2 return intermediaries for HTTP/2 CONNECT
Diffstat (limited to 'test')
-rw-r--r--test/raw_SUITE.erl6
-rw-r--r--test/rfc7540_SUITE.erl16
2 files changed, 19 insertions, 3 deletions
diff --git a/test/raw_SUITE.erl b/test/raw_SUITE.erl
index 9b836c0..c3eec1d 100644
--- a/test/raw_SUITE.erl
+++ b/test/raw_SUITE.erl
@@ -187,9 +187,13 @@ connect_raw_reply_to(_) ->
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."),
+ doc("Use CONNECT over clear HTTP/2 to connect to a remote endpoint using the raw protocol over TCP."),
do_h2_connect_raw(tcp, tcp).
+h2_connect_tls_raw_tcp(_) ->
+ doc("Use CONNECT over secure HTTP/2 to connect to a remote endpoint using the raw protocol over TCP."),
+ do_h2_connect_raw(tcp, tls).
+
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, [
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 09a0923..ac36ee6 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -62,7 +62,7 @@ do_proxy_init(Proxy=#proxy{parent=Parent, transport=Transport}) ->
gen_tcp:listen(0, [binary, {active, false}]);
gun_tls ->
Opts = ct_helper:get_certs_from_ets(),
- ssl:listen(0, [binary, {active, false}|Opts])
+ ssl:listen(0, [binary, {active, false}, {alpn_preferred_protocols, [<<"h2">>]}|Opts])
end,
{ok, {_, Port}} = Transport:sockname(ListenSocket),
Parent ! {self(), Port},
@@ -435,6 +435,11 @@ connect_http(_) ->
"to an HTTP/1.1 server via a TCP HTTP/2 proxy. (RFC7540 8.3)"),
do_connect_http(<<"http">>, tcp, <<"http">>, tcp).
+connect_https(_) ->
+ doc("CONNECT can be used to establish a TCP connection "
+ "to an HTTP/1.1 server via a TLS HTTP/2 proxy. (RFC7540 8.3)"),
+ do_connect_http(<<"http">>, tcp, <<"https">>, tls).
+
do_connect_http(OriginScheme, OriginTransport, ProxyScheme, ProxyTransport) ->
{ok, OriginPid, OriginPort} = init_origin(OriginTransport, http),
{ok, ProxyPid, ProxyPort} = do_proxy_start(ProxyTransport, [
@@ -485,6 +490,13 @@ do_connect_http(OriginScheme, OriginTransport, ProxyScheme, ProxyTransport) ->
{ok, #{
ref := ProxiedStreamRef,
reply_to := Self,
- state := running
+ state := running,
+ intermediaries := [#{
+ type := connect,
+ host := "localhost",
+ port := ProxyPort,
+ transport := ProxyTransport,
+ protocol := http2
+ }]
}} = gun:stream_info(ConnPid, ProxiedStreamRef),
gun:close(ConnPid).