diff --git a/lib/Test/Nginx/Socket.pm b/lib/Test/Nginx/Socket.pm index a03ce17b..2befa7f4 100644 --- a/lib/Test/Nginx/Socket.pm +++ b/lib/Test/Nginx/Socket.pm @@ -2125,6 +2125,11 @@ sub gen_curl_cmd_from_req ($$) { push @args, '--http2', '--http2-prior-knowledge'; } + if (use_http2($block) && defined $block->tls) { + my $resolve = "$ServerName:$ServerPortForClient:$ServerAddr"; + push @args, '-k', '--resolve', $resolve; + } + if ($meth eq 'HEAD') { push @args, '-I'; @@ -2191,6 +2196,10 @@ sub gen_curl_cmd_from_req ($$) { my $server = $ServerAddr; my $port = $ServerPortForClient; $link = "http://$server:$port$uri"; + if (use_http2($block) && defined $block->tls) { + my $server_name = $ServerName; + $link = "https://$server_name:$port$uri"; + } } push @args, $link; @@ -2864,6 +2873,7 @@ The following sections are supported: =head2 http2 Enforces the test scaffold to use the HTTP/2 wire protocol to send the test request. +Also, you can set tls section using the HTTP/2 over TLS protocol and SNI(Server Name Indication). Under the hood, the test scaffold uses the `curl` command-line utility to do the wire communication with the NGINX server. The `curl` utility must be recent enough to support both the C<--http2> @@ -3991,6 +4001,10 @@ One can enable HTTP/2 mode for an individual test block by specifying the L section, as in + + --- tls + =head2 TEST_NGINX_VERBOSE Controls whether to output verbose debugging messages in Test::Nginx. Default to empty. diff --git a/lib/Test/Nginx/Util.pm b/lib/Test/Nginx/Util.pm index 5d684378..88a67da1 100644 --- a/lib/Test/Nginx/Util.pm +++ b/lib/Test/Nginx/Util.pm @@ -942,6 +942,10 @@ _EOC_ my $listen_opts = ''; + if (use_http2($block) && defined $block->tls) { + $listen_opts .= " ssl"; + } + if (use_http2($block)) { $listen_opts .= " http2"; }