-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: added --- sni Support TLS http2 and SNI #68
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2121,8 +2121,11 @@ sub gen_curl_cmd_from_req ($$) { | |
push @args, '-sS'; | ||
} | ||
|
||
if (use_http2($block)) { | ||
my $isHttp2 = use_http2($block); | ||
if ($isHttp2 && $isHttp2 == 1) { | ||
push @args, '--http2', '--http2-prior-knowledge'; | ||
} elsif ($isHttp2 && $isHttp2 == 2) { | ||
push @args, '-k', '--http2', '--http2-prior-knowledge', '--resolve', "$ServerName:$ServerPortForClient:$ServerAddr", | ||
} | ||
|
||
if ($meth eq 'HEAD') { | ||
|
@@ -2193,6 +2196,10 @@ sub gen_curl_cmd_from_req ($$) { | |
$link = "http://$server:$port$uri"; | ||
} | ||
|
||
if (use_http2($block) == 2) { | ||
$link = "https://$ServerName:$ServerPortForClient$uri"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SSL support need proper server certificate and private keys. And it's a burden for the test writer to prepare such things themselves. We should make HTTP/2 over TLS test mode work on most of the existing test suite written for HTTP/1. So we should automatically generate such self-signed server certificate/key pair ourselves in the test scaffold. |
||
} | ||
|
||
push @args, $link; | ||
|
||
return \@args; | ||
|
@@ -3977,7 +3984,7 @@ starts. The following environment variables are supported by this module: | |
=head2 TEST_NGINX_USE_HTTP2 | ||
|
||
Enables the "http2" test mode by enforcing using the (plain text) HTTP/2 protocol to send the | ||
test request. | ||
test request. Also, you can set sni section using the TLS HTTP/2 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 +3998,10 @@ One can enable HTTP/2 mode for an individual test block by specifying the L<http | |
|
||
--- http2 | ||
|
||
Enable SNI mode for an individual test block by specifying the L<sni> section, as in | ||
|
||
--- sni | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your review and comments. I'll change it. |
||
|
||
=head2 TEST_NGINX_VERBOSE | ||
|
||
Controls whether to output verbose debugging messages in Test::Nginx. Default to empty. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -942,8 +942,11 @@ _EOC_ | |
|
||
my $listen_opts = ''; | ||
|
||
if (use_http2($block)) { | ||
my $isHttp2 = use_http2($block); | ||
if ($isHttp2 && $isHttp2 == 1) { | ||
$listen_opts .= " http2"; | ||
} elsif ($isHttp2 && $isHttp2 == 2) { | ||
$listen_opts .= " ssl http2"; | ||
} | ||
|
||
print $out <<_EOC_; | ||
|
@@ -2499,6 +2502,11 @@ sub use_http2 ($) { | |
bail_out("cannot use --- http2 with --- pipelined_requests"); | ||
} | ||
|
||
if (defined $block->sni) { | ||
$block->set_value("test_nginx_enabled_http2_sni", 1); | ||
return 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use_http2 function returns a boolean value. It's not a good idea to make it return more complex encodings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'll change it. |
||
} | ||
|
||
$block->set_value("test_nginx_enabled_http2", 1); | ||
return 1; | ||
} | ||
|
@@ -2527,6 +2535,11 @@ sub use_http2 ($) { | |
return undef; | ||
} | ||
|
||
if ($block->sni) { | ||
$block->set_value("test_nginx_enabled_http2_sni", 1); | ||
return 2; | ||
} | ||
|
||
$block->set_value("test_nginx_enabled_http2", 1); | ||
return 1; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not use "camel case" identifier names in this Perl project. We use "snake case" consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'll change it.