changeset 1732:41ca4b00c2d0

Tests: added absolute_redirect and Location tests for HTTP/2.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 15 Sep 2021 20:32:11 +0300
parents c9b4c0ef5059
children e306bd77321d
files h2_absolute_redirect.t
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
copy from http_absolute_redirect.t
copy to h2_absolute_redirect.t
--- a/http_absolute_redirect.t
+++ b/h2_absolute_redirect.t
@@ -16,13 +16,14 @@ BEGIN { use FindBin; chdir($FindBin::Bin
 
 use lib 'lib';
 use Test::Nginx;
+use Test::Nginx::HTTP2;
 
 ###############################################################################
 
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)
+my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -38,7 +39,7 @@ http {
     absolute_redirect off;
 
     server {
-        listen       127.0.0.1:8080;
+        listen       127.0.0.1:8080 http2;
         server_name  on;
 
         absolute_redirect on;
@@ -74,7 +75,7 @@ http {
     }
 
     server {
-        listen       127.0.0.1:8080;
+        listen       127.0.0.1:8080 http2;
         server_name  off;
 
         location / { }
@@ -206,11 +207,13 @@ like(get('off', '/auto%20%22%23%25%3C%3E
 
 sub get {
 	my ($host, $uri) = @_;
-	http(<<EOF);
-GET $uri HTTP/1.0
-Host: $host
 
-EOF
+	my $s = Test::Nginx::HTTP2->new();
+	my $sid = $s->new_stream({ host => $host, path => $uri });
+	my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
+
+	my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+	return 'Location: ' . $frame->{headers}->{'location'};
 }
 
 ###############################################################################