annotate h2_proxy_cache.t @ 997:3c5d3b384d3f

Tests: adjusted TODOs for HTTP/2 fixes committed in 1.11.3.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 26 Jul 2016 21:00:41 +0300
parents ec9b99d3e22e
children efccab043dd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
2
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
5
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
6 # Tests for HTTP/2 protocol with cache.
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
7
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
8 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
9
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
10 use warnings;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
11 use strict;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
12
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
13 use Test::More;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
14
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
16
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
17 use lib 'lib';
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
19 use Test::Nginx::HTTP2;
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
20
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
21 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
22
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
25
996
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy cache rewrite/)->plan(12)
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
27 ->write_file_expand('nginx.conf', <<'EOF');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
28
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
30
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
31 daemon off;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
32
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
33 events {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
34 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
35
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
36 http {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
38
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
39 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
40
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
41 # quit unfixed nginx timely on different linuces
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
42 http2_idle_timeout 2s;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
43 http2_recv_timeout 2s;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
44
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
45 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
46 listen 127.0.0.1:8080 http2;
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
47 listen 127.0.0.1:8081;
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
48 server_name localhost;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
49
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
50 location /cache {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
51 proxy_pass http://127.0.0.1:8081/;
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
52 proxy_cache NAME;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
53 proxy_cache_valid 1m;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
54 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
55 location /proxy_buffering_off {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
56 proxy_pass http://127.0.0.1:8081/;
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
57 proxy_cache NAME;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
58 proxy_cache_valid 1m;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
59 proxy_buffering off;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
60 }
996
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
61 location / {
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
62 if ($arg_slow) {
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
63 set $limit_rate 200;
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
64 }
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
65 }
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
66 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
67 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
68
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
69 EOF
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
70
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
71 $t->write_file('t.html', 'SEE-THIS');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
72 $t->run();
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
73
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
74 ###############################################################################
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
75
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
76 # simple proxy cache test
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
77
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
78 my $s = Test::Nginx::HTTP2->new();
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
79 my $sid = $s->new_stream({ path => '/cache/t.html' });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
80 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
81
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
82 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
83 is($frame->{headers}->{':status'}, '200', 'proxy cache');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
84
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
85 my $etag = $frame->{headers}->{'etag'};
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
86
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
87 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
88 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
89 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
90
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
91 $t->write_file('t.html', 'NOOP');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
92
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
93 $sid = $s->new_stream({ headers => [
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
94 { name => ':method', value => 'GET', mode => 0 },
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
95 { name => ':scheme', value => 'http', mode => 0 },
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
96 { name => ':path', value => '/cache/t.html' },
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
97 { name => ':authority', value => 'localhost', mode => 1 },
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
98 { name => 'if-none-match', value => $etag }]});
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
99 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
100
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
101 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
102 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
103
885
a1e76cca714c Tests: fixed HTTP/2 tests with proxy cache after a6abbfed42c0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 884
diff changeset
104 $t->write_file('t.html', 'SEE-THIS');
a1e76cca714c Tests: fixed HTTP/2 tests with proxy cache after a6abbfed42c0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 884
diff changeset
105
884
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
106 # request body with cached response
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
107
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
108 $sid = $s->new_stream({ path => '/cache/t.html', body_more => 1 });
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
109 $s->h2_body('TEST');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
110 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
884
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
111
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
112 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
113 is($frame->{headers}->{':status'}, 200, 'proxy cache - request body');
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
114
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
115 $s->h2_ping('SEE-THIS');
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
116 $frames = $s->read(all => [{ type => 'PING' }]);
884
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
117
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
118 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
119 ok($frame, 'proxy cache - request body - next');
d1b94c1127d6 Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 876
diff changeset
120
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
121 # HEADERS could be received with fin, followed by DATA
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
122
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
123 $s = Test::Nginx::HTTP2->new();
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
124 $sid = $s->new_stream({ path => '/cache/t.html?1', method => 'HEAD' });
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
125
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
126 $frames = $s->read(all => [{ sid => $sid, fin => 1 }], wait => 0.2);
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
127 push @$frames, $_ for @{$s->read(all => [{ sid => $sid }], wait => 0.2)};
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
128 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
129
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
130 # proxy cache - expect no stray empty DATA frame
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
131
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
132 TODO: {
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
133 local $TODO = 'not yet';
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
134
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
135 $s = Test::Nginx::HTTP2->new();
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
136 $sid = $s->new_stream({ path => '/cache/t.html?2' });
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
137
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
138 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
139 my @data = grep ({ $_->{type} eq "DATA" } @$frames);
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
140 is(@data, 1, 'proxy cache write - data frames');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
141 is(join(' ', map { $_->{data} } @data), 'SEE-THIS', 'proxy cache write - data');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
142 is(join(' ', map { $_->{flags} } @data), '1', 'proxy cache write - flags');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
143
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
144 }
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
145
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
146 # HEAD on empty cache with proxy_buffering off
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
147
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
148 $s = Test::Nginx::HTTP2->new();
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
149 $sid = $s->new_stream(
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
150 { path => '/proxy_buffering_off/t.html?1', method => 'HEAD' });
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
151
948
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
152 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
4dc302d8e04f Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents: 945
diff changeset
153 push @$frames, $_ for @{$s->read(all => [{ sid => $sid }], wait => 0.2)};
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
154 ok(!grep ({ $_->{type} eq "DATA" } @$frames),
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
155 'proxy cache HEAD buffering off - no body');
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
156
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
157 # client cancels stream with a cacheable request that was sent to upstream
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
158 # HEADERS should not be produced for the canceled stream
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
159
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
160 $s = Test::Nginx::HTTP2->new();
996
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
161 $sid = $s->new_stream({ path => '/cache/t.html?slow=1' });
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
162
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
163 $s->h2_rst($sid, 8);
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
164
996
ec9b99d3e22e Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 986
diff changeset
165 $frames = $s->read(all => [{ sid => $sid, fin => 0x4 }], wait => 1.2);
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
166
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
167 TODO: {
997
3c5d3b384d3f Tests: adjusted TODOs for HTTP/2 fixes committed in 1.11.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 996
diff changeset
168 local $TODO = 'not yet' unless $t->has_version('1.11.3');
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
169
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
170 ok(!(grep { $_->{type} eq "HEADERS" } @$frames), 'no headers');
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
171
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
172 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
173
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
174 # client closes connection after sending a cacheable request producing alert
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
175
997
3c5d3b384d3f Tests: adjusted TODOs for HTTP/2 fixes committed in 1.11.3.
Sergey Kandaurov <pluknet@nginx.com>
parents: 996
diff changeset
176 $t->todo_alerts() unless $t->has_version('1.11.3');
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
177
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
178 $s = Test::Nginx::HTTP2->new();
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
179 $sid = $s->new_stream({ path => '/cache/t.html?4' });
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
180
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
181 undef $s;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
182 select undef, undef, undef, 0.2;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
183
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
184 $t->stop();
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 985
diff changeset
185
876
a6abbfed42c0 Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff changeset
186 ###############################################################################