comparison h2_cache.t @ 884:d1b94c1127d6

Tests: added HTTP/2 tests for request body with cached response.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 25 Mar 2016 04:40:27 +0300
parents a6abbfed42c0
children a1e76cca714c
comparison
equal deleted inserted replaced
883:8c3fa5a94743 884:d1b94c1127d6
14 14
15 BEGIN { use FindBin; chdir($FindBin::Bin); } 15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16 16
17 use lib 'lib'; 17 use lib 'lib';
18 use Test::Nginx; 18 use Test::Nginx;
19 use Test::Nginx::HTTP2; 19 use Test::Nginx::HTTP2 qw/ :DEFAULT :frame /;
20 20
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http http_v2 cache/)->plan(9) 26 my $t = Test::Nginx->new()->has(qw/http http_v2 cache/)->plan(11)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
90 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 90 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
91 91
92 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 92 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
93 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional'); 93 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
94 94
95 # request body with cached response
96
97 $sid = new_stream($sess, { path => '/cache/t.html', body_more => 1 });
98 h2_body($sess, 'TEST');
99 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
100
101 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
102 is($frame->{headers}->{':status'}, 200, 'proxy cache - request body');
103
104 h2_ping($sess, 'SEE-THIS');
105 $frames = h2_read($sess, all => [{ type => 'PING' }]);
106
107 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
108 ok($frame, 'proxy cache - request body - next');
109
95 # HEADERS could be received with fin, followed by DATA 110 # HEADERS could be received with fin, followed by DATA
96 111
97 $sess = new_session(); 112 $sess = new_session();
98 $sid = new_stream($sess, { path => '/cache/t.html?1', method => 'HEAD' }); 113 $sid = new_stream($sess, { path => '/cache/t.html?1', method => 'HEAD' });
99 114