changeset 764:5dcd998daace

Tests: fixed HTTP/2 proxy cache tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 28 Oct 2015 00:11:45 +0300
parents 2ba4058848d6
children 14d6f69b7d9d
files h2.t
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/h2.t
+++ b/h2.t
@@ -135,14 +135,15 @@ http {
             add_header X-UC-a $upstream_cookie_a;
             add_header X-UC-c $upstream_cookie_c;
             proxy_pass http://127.0.0.1:8083/;
-            proxy_cache NAME;
-            proxy_cache_valid 1m;
             proxy_set_header X-Cookie-a $cookie_a;
             proxy_set_header X-Cookie-c $cookie_c;
         }
         location /proxy2/ {
             add_header X-Body "$request_body";
             proxy_pass http://127.0.0.1:8081/;
+        }
+        location /cache/ {
+            proxy_pass http://127.0.0.1:8081/;
             proxy_cache NAME;
             proxy_cache_valid 1m;
         }
@@ -270,6 +271,7 @@ open STDERR, ">&", \*OLDERR;
 
 $t->write_file('t2.html', 'SEE-THIS');
 $t->write_file('t3.html', 'SEE-THIS');
+$t->write_file('t4.html', 'SEE-THIS');
 
 my %cframe = (
 	0 => { name => 'DATA', value => \&data },
@@ -1300,7 +1302,7 @@ gunzip_like($frame->{data}, qr/^SEE-THIS
 # simple proxy cache test
 
 $sess = new_session();
-$sid = new_stream($sess, { path => '/proxy2/t2.html?2' });
+$sid = new_stream($sess, { path => '/cache/t4.html' });
 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
 
 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
@@ -1312,10 +1314,12 @@ my $etag = $frame->{headers}->{'etag'};
 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
 
+$t->write_file('t4.html', 'NOOP');
+
 $sid = new_stream($sess, { headers => [
 	{ name => ':method', value => 'GET', mode => 0 },
 	{ name => ':scheme', value => 'http', mode => 0 },
-	{ name => ':path', value => '/proxy2/t2.html?2' },
+	{ name => ':path', value => '/cache/t4.html' },
 	{ name => ':authority', value => 'localhost', mode => 1 },
 	{ name => 'if-none-match', value => $etag }]});
 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
@@ -1326,7 +1330,7 @@ is($frame->{headers}->{':status'}, 304, 
 # HEADERS could be received with fin, followed by DATA
 
 $sess = new_session();
-$sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' });
+$sid = new_stream($sess, { path => '/cache/t2.html?1', method => 'HEAD' });
 
 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};