Mercurial > hg > nginx-tests
comparison h2_proxy_cache.t @ 986:99f93be57416
Tests: various HTTP/2 tests with canceled stream.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 20 Jul 2016 11:07:22 +0300 |
parents | de513b115e68 |
children | ec9b99d3e22e |
comparison
equal
deleted
inserted
replaced
985:de513b115e68 | 986:99f93be57416 |
---|---|
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 proxy cache/)->plan(11) | 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy cache/)->plan(12) |
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; |
35 | 35 |
36 http { | 36 http { |
37 %%TEST_GLOBALS_HTTP%% | 37 %%TEST_GLOBALS_HTTP%% |
38 | 38 |
39 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; | 39 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; |
40 | |
41 # quit unfixed nginx timely on different linuces | |
42 http2_idle_timeout 2s; | |
43 http2_recv_timeout 2s; | |
40 | 44 |
41 server { | 45 server { |
42 listen 127.0.0.1:8080 http2; | 46 listen 127.0.0.1:8080 http2; |
43 listen 127.0.0.1:8081; | 47 listen 127.0.0.1:8081; |
44 server_name localhost; | 48 server_name localhost; |
143 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 147 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
144 push @$frames, $_ for @{$s->read(all => [{ sid => $sid }], wait => 0.2)}; | 148 push @$frames, $_ for @{$s->read(all => [{ sid => $sid }], wait => 0.2)}; |
145 ok(!grep ({ $_->{type} eq "DATA" } @$frames), | 149 ok(!grep ({ $_->{type} eq "DATA" } @$frames), |
146 'proxy cache HEAD buffering off - no body'); | 150 'proxy cache HEAD buffering off - no body'); |
147 | 151 |
152 # client cancels stream with a cacheable request that was sent to upstream | |
153 # HEADERS should not be produced for the canceled stream | |
154 | |
155 $s = Test::Nginx::HTTP2->new(); | |
156 $sid = $s->new_stream({ path => '/cache/t.html?3' }); | |
157 | |
158 $s->h2_rst($sid, 8); | |
159 | |
160 $frames = $s->read(all => [{ sid => $sid, fin => 0x4 }], wait => 0.2); | |
161 | |
162 TODO: { | |
163 local $TODO = 'not yet'; | |
164 | |
165 ok(!(grep { $_->{type} eq "HEADERS" } @$frames), 'no headers'); | |
166 | |
167 } | |
168 | |
169 # client closes connection after sending a cacheable request producing alert | |
170 | |
171 $t->todo_alerts(); | |
172 | |
173 $s = Test::Nginx::HTTP2->new(); | |
174 $sid = $s->new_stream({ path => '/cache/t.html?4' }); | |
175 | |
176 undef $s; | |
177 select undef, undef, undef, 0.2; | |
178 | |
179 $t->stop(); | |
180 | |
148 ############################################################################### | 181 ############################################################################### |