`t/50connect-proxy-status.t`: test transports http/1 https/1 and https/2
@@ -29,29 +29,41 @@ EOT
my $ok_resp = qr{HTTP/[^ ]+ 200\s}m;
subtest "basic", sub {
- my $content = `curl --http1.1 -p -x 127.0.0.1:$server->{port} --silent -v --show-error http://127.0.0.1:$origin_port/echo 2>&1`;
+ run_with_curl($server, sub {
+ my ($proto, $port, $curl) = @_;
+ my $content = `$curl --proxy-insecure -p -x $proto://127.0.0.1:$port --silent -v --show-error http://127.0.0.1:$origin_port/echo 2>&1`;
like $content, qr{Proxy replied 200 to CONNECT request}m, "Connect got a 200 response to CONNECT";
my @c = $content =~ /$ok_resp/g;
is @c, 2, "Got two 200 responses";
+ });
};
subtest "acl" => sub {
- my $content = `curl --http1.1 -p -x 127.0.0.1:$server->{port} --silent -v --show-error https://8.8.8.8/ 2>&1`;
+ run_with_curl($server, sub {
+ my ($proto, $port, $curl) = @_;
+ my $content = `$curl --proxy-insecure -p -x $proto://127.0.0.1:$port --silent -v --show-error https://8.8.8.8/ 2>&1`;
like $content, qr{proxy-status: h2o/test; error=destination_ip_prohibited; next-hop="8\.8\.8\.8"}i;
like $content, qr{Received HTTP code 403 from proxy after CONNECT};
+ });
};
subtest "nxdomain" => sub {
- my $content = `curl --http1.1 -p -x 127.0.0.1:$server->{port} --silent -v --show-error https://doesnotexist.xip.io/ 2>&1`;
+ run_with_curl($server, sub {
+ my ($proto, $port, $curl) = @_;
+ my $content = `$curl --proxy-insecure -p -x $proto://127.0.0.1:$port --silent -v --show-error https://doesnotexist.xip.io/ 2>&1`;
like $content, qr{proxy-status: h2o/test; error=dns_error; rcode=NXDOMAIN; next-hop="doesnotexist.xip.io"}i;
like $content, qr{Received HTTP code 502 from proxy after CONNECT};
+ });
};
# This test assumes that nothing listens on port 1 (tcpmux).
subtest "refused" => sub {
- my $content = `curl --http1.1 -p -x 127.0.0.1:$server->{port} --silent -v --show-error https://127.0.0.1:1/ 2>&1`;
+ run_with_curl($server, sub {
+ my ($proto, $port, $curl) = @_;
+ my $content = `$curl --proxy-insecure -p -x $proto://127.0.0.1:$port --silent -v --show-error https://127.0.0.1:1/ 2>&1`;
like $content, qr{proxy-status: h2o/test; error=connection_refused; next-hop="127\.0\.0\.1"}i;
like $content, qr{Received HTTP code 502 from proxy after CONNECT};
+ });
};
done_testing;
