Mercurial > hg > nginx-tests
annotate h2_proxy_cache.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
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 |
1462
fe886814b25a
Tests: removed HTTP/2 proxy cache TODO tests for empty DATA frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1253
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy cache/)->plan(9) |
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 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
41 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
42 listen 127.0.0.1:8080; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 listen 127.0.0.1:8081; |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
44 server_name localhost; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
45 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
46 http2 on; |
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
47 |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
48 location /cache { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 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
|
50 proxy_cache NAME; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
51 proxy_cache_valid 1m; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
52 } |
1252
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
53 |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
54 location /proxy_buffering_off { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
55 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
|
56 proxy_cache NAME; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
57 proxy_cache_valid 1m; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
58 proxy_buffering off; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
59 } |
1252
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
60 |
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
61 location / { } |
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
62 |
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
63 location /slow { |
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
64 limit_rate 200; |
996
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'); |
1252
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
72 $t->write_file('slow.html', 'SEE-THIS'); |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 $t->run(); |
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 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 # simple proxy cache test |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
84 is($frame->{headers}->{':status'}, '200', 'proxy cache'); |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 my $etag = $frame->{headers}->{'etag'}; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
89 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
|
90 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
|
91 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
92 $t->write_file('t.html', 'NOOP'); |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
93 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
94 $sid = $s->new_stream({ headers => [ |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
95 { name => ':method', value => 'GET', mode => 0 }, |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
96 { name => ':scheme', value => 'http', mode => 0 }, |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
97 { name => ':path', value => '/cache/t.html' }, |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
98 { name => ':authority', value => 'localhost', mode => 1 }, |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
99 { 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
|
100 $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
|
101 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
102 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
103 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
|
104 |
885
a1e76cca714c
Tests: fixed HTTP/2 tests with proxy cache after a6abbfed42c0.
Sergey Kandaurov <pluknet@nginx.com>
parents:
884
diff
changeset
|
105 $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
|
106 |
884
d1b94c1127d6
Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
876
diff
changeset
|
107 # 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
|
108 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
109 $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
|
110 $s->h2_body('TEST'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
111 $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
|
112 |
d1b94c1127d6
Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
876
diff
changeset
|
113 ($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
|
114 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
|
115 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
116 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
117 $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
|
118 |
d1b94c1127d6
Tests: added HTTP/2 tests for request body with cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
876
diff
changeset
|
119 ($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
|
120 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
|
121 |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
122 # 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
|
123 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
124 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
125 $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
|
126 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
127 $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
|
128 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
|
129 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
|
130 |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
131 # 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
|
132 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
133 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
134 $sid = $s->new_stream( |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
135 { 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
|
136 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
137 $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
|
138 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
|
139 ok(!grep ({ $_->{type} eq "DATA" } @$frames), |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
140 'proxy cache HEAD buffering off - no body'); |
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
141 |
1253
86e6287707ee
Tests: skip "no headers" test in h2_proxy_cache.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1252
diff
changeset
|
142 SKIP: { |
86e6287707ee
Tests: skip "no headers" test in h2_proxy_cache.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1252
diff
changeset
|
143 skip 'win32', 1 if $^O eq 'MSWin32'; |
86e6287707ee
Tests: skip "no headers" test in h2_proxy_cache.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1252
diff
changeset
|
144 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
145 # 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
|
146 # 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
|
147 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
148 $s = Test::Nginx::HTTP2->new(); |
1252
93453d7858ce
Tests: removed rewrite dependency in h2_proxy_cache.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
149 $sid = $s->new_stream({ path => '/cache/slow.html' }); |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
150 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
151 $s->h2_rst($sid, 8); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
152 |
996
ec9b99d3e22e
Tests: fixed HTTP/2 test for no HEADERS due to canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
986
diff
changeset
|
153 $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
|
154 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
|
155 |
1253
86e6287707ee
Tests: skip "no headers" test in h2_proxy_cache.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1252
diff
changeset
|
156 } |
86e6287707ee
Tests: skip "no headers" test in h2_proxy_cache.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1252
diff
changeset
|
157 |
986
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
158 # 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
|
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(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
161 $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
|
162 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
163 undef $s; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
164 select undef, undef, undef, 0.2; |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
165 |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
166 $t->stop(); |
99f93be57416
Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
985
diff
changeset
|
167 |
876
a6abbfed42c0
Tests: split HTTP/2 tests, HTTP2 package introduced.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
168 ############################################################################### |