comparison h2.t @ 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
comparison
equal deleted inserted replaced
763:2ba4058848d6 764:5dcd998daace
133 } 133 }
134 location /proxy/ { 134 location /proxy/ {
135 add_header X-UC-a $upstream_cookie_a; 135 add_header X-UC-a $upstream_cookie_a;
136 add_header X-UC-c $upstream_cookie_c; 136 add_header X-UC-c $upstream_cookie_c;
137 proxy_pass http://127.0.0.1:8083/; 137 proxy_pass http://127.0.0.1:8083/;
138 proxy_cache NAME;
139 proxy_cache_valid 1m;
140 proxy_set_header X-Cookie-a $cookie_a; 138 proxy_set_header X-Cookie-a $cookie_a;
141 proxy_set_header X-Cookie-c $cookie_c; 139 proxy_set_header X-Cookie-c $cookie_c;
142 } 140 }
143 location /proxy2/ { 141 location /proxy2/ {
144 add_header X-Body "$request_body"; 142 add_header X-Body "$request_body";
143 proxy_pass http://127.0.0.1:8081/;
144 }
145 location /cache/ {
145 proxy_pass http://127.0.0.1:8081/; 146 proxy_pass http://127.0.0.1:8081/;
146 proxy_cache NAME; 147 proxy_cache NAME;
147 proxy_cache_valid 1m; 148 proxy_cache_valid 1m;
148 } 149 }
149 location /proxy_buffering_off { 150 location /proxy_buffering_off {
268 $t->write_file('tbig.html', 269 $t->write_file('tbig.html',
269 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000))); 270 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000)));
270 271
271 $t->write_file('t2.html', 'SEE-THIS'); 272 $t->write_file('t2.html', 'SEE-THIS');
272 $t->write_file('t3.html', 'SEE-THIS'); 273 $t->write_file('t3.html', 'SEE-THIS');
274 $t->write_file('t4.html', 'SEE-THIS');
273 275
274 my %cframe = ( 276 my %cframe = (
275 0 => { name => 'DATA', value => \&data }, 277 0 => { name => 'DATA', value => \&data },
276 1 => { name => 'HEADERS', value => \&headers }, 278 1 => { name => 'HEADERS', value => \&headers },
277 # 2 => { name => 'PRIORITY', value => \&priority }, 279 # 2 => { name => 'PRIORITY', value => \&priority },
1298 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA'); 1300 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA');
1299 1301
1300 # simple proxy cache test 1302 # simple proxy cache test
1301 1303
1302 $sess = new_session(); 1304 $sess = new_session();
1303 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' }); 1305 $sid = new_stream($sess, { path => '/cache/t4.html' });
1304 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 1306 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
1305 1307
1306 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 1308 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
1307 is($frame->{headers}->{':status'}, '200', 'proxy cache'); 1309 is($frame->{headers}->{':status'}, '200', 'proxy cache');
1308 1310
1310 1312
1311 ($frame) = grep { $_->{type} eq "DATA" } @$frames; 1313 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
1312 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA'); 1314 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
1313 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload'); 1315 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
1314 1316
1315 $sid = new_stream($sess, { headers => [ 1317 $t->write_file('t4.html', 'NOOP');
1316 { name => ':method', value => 'GET', mode => 0 }, 1318
1317 { name => ':scheme', value => 'http', mode => 0 }, 1319 $sid = new_stream($sess, { headers => [
1318 { name => ':path', value => '/proxy2/t2.html?2' }, 1320 { name => ':method', value => 'GET', mode => 0 },
1321 { name => ':scheme', value => 'http', mode => 0 },
1322 { name => ':path', value => '/cache/t4.html' },
1319 { name => ':authority', value => 'localhost', mode => 1 }, 1323 { name => ':authority', value => 'localhost', mode => 1 },
1320 { name => 'if-none-match', value => $etag }]}); 1324 { name => 'if-none-match', value => $etag }]});
1321 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 1325 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
1322 1326
1323 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 1327 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
1324 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional'); 1328 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
1325 1329
1326 # HEADERS could be received with fin, followed by DATA 1330 # HEADERS could be received with fin, followed by DATA
1327 1331
1328 $sess = new_session(); 1332 $sess = new_session();
1329 $sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' }); 1333 $sid = new_stream($sess, { path => '/cache/t2.html?1', method => 'HEAD' });
1330 1334
1331 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 1335 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
1332 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])}; 1336 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
1333 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body'); 1337 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
1334 1338