Mercurial > hg > nginx-tests
annotate 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 | 196d33c2bb45 |
children |
rev | line source |
---|---|
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for http proxy cache. |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
104
8bc9de6559a1
Tests: add gzip module checks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
101
diff
changeset
|
12 use Test::More; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
17 use Test::Nginx qw/ :DEFAULT :gzip /; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(15) |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
120
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
106
diff
changeset
|
27 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
106
diff
changeset
|
28 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
233
diff
changeset
|
29 daemon off; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 events { |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 http { |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
106
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
424
diff
changeset
|
38 keys_zone=NAME:1m; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 server_name localhost; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
44 gzip on; |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
45 gzip_min_length 0; |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
46 |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 proxy_pass http://127.0.0.1:8081; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 proxy_cache NAME; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
749
d1da28e28d1d
Tests: adjusted proxy_cache.t timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
713
diff
changeset
|
52 proxy_cache_valid 200 302 2s; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 proxy_cache_valid 301 1d; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 proxy_cache_valid any 1m; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 proxy_cache_min_uses 1; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
58 proxy_cache_use_stale error timeout invalid_header http_500 |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
59 http_404; |
424
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
60 |
912
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
61 proxy_no_cache $arg_e; |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
62 |
424
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
63 add_header X-Cache-Status $upstream_cache_status; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
67 listen 127.0.0.1:8081; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 server_name localhost; |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 location / { |
912
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
71 limit_rate 512; |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 } |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 EOF |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 $t->write_file('t.html', 'SEE-THIS'); |
80
14cf2658592d
Tests: add more proxy_cache tests, remove obsolete clean_time.
Maxim Dounin <mdounin@mdounin.ru>
parents:
74
diff
changeset
|
79 $t->write_file('t2.html', 'SEE-THIS'); |
99
f92852da34aa
Tests: add test for empty cached response.
Maxim Dounin <mdounin@mdounin.ru>
parents:
80
diff
changeset
|
80 $t->write_file('empty.html', ''); |
912
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
81 $t->write_file('big.html', 'x' x 1024); |
295
6fe0459b6668
Tests: eliminate startup races in proxy and fastcgi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
82 |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
295
diff
changeset
|
83 $t->run(); |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 ############################################################################### |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 like(http_get('/t.html'), qr/SEE-THIS/, 'proxy request'); |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 $t->write_file('t.html', 'NOOP'); |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 like(http_get('/t.html'), qr/SEE-THIS/, 'proxy request cached'); |
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
80
14cf2658592d
Tests: add more proxy_cache tests, remove obsolete clean_time.
Maxim Dounin <mdounin@mdounin.ru>
parents:
74
diff
changeset
|
92 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head request'); |
14cf2658592d
Tests: add more proxy_cache tests, remove obsolete clean_time.
Maxim Dounin <mdounin@mdounin.ru>
parents:
74
diff
changeset
|
93 like(http_get('/t2.html'), qr/SEE-THIS/, 'get after head'); |
14cf2658592d
Tests: add more proxy_cache tests, remove obsolete clean_time.
Maxim Dounin <mdounin@mdounin.ru>
parents:
74
diff
changeset
|
94 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head after get'); |
14cf2658592d
Tests: add more proxy_cache tests, remove obsolete clean_time.
Maxim Dounin <mdounin@mdounin.ru>
parents:
74
diff
changeset
|
95 |
424
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
96 like(http_head('/empty.html?head'), qr/MISS/, 'empty head first'); |
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
97 like(http_head('/empty.html?head'), qr/HIT/, 'empty head second'); |
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
98 |
145
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
99 like(http_get_range('/t.html', 'Range: bytes=4-'), qr/^THIS/m, 'cached range'); |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
100 like(http_get_range('/t.html', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms, |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
101 'cached multipart range'); |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
102 |
424
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
103 like(http_get('/empty.html'), qr/MISS/, 'empty get first'); |
e402c5ed57eb
Tests: caching of empty responses on HEAD requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
104 like(http_get('/empty.html'), qr/HIT/, 'empty get second'); |
120
598b758c68a9
Tests: empty cached responses partially fixed in 0.8.31.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
105 |
749
d1da28e28d1d
Tests: adjusted proxy_cache.t timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
713
diff
changeset
|
106 select(undef, undef, undef, 3.1); |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
107 unlink $t->testdir() . '/t.html'; |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
108 like(http_gzip_request('/t.html'), |
713
94033cdc2f78
Tests: adjusted proxy_cache.t timeout to get stale cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
593
diff
changeset
|
109 qr/HTTP.*STALE.*1c\x0d\x0a.{28}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s, |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
110 'non-empty get stale'); |
120
598b758c68a9
Tests: empty cached responses partially fixed in 0.8.31.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
111 |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
112 unlink $t->testdir() . '/empty.html'; |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
113 like(http_gzip_request('/empty.html'), |
713
94033cdc2f78
Tests: adjusted proxy_cache.t timeout to get stale cached response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
593
diff
changeset
|
114 qr/HTTP.*STALE.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s, |
101
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
115 'empty get stale'); |
6303927c18d2
Tests: proxy cache tests for problems with duplicate final chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
99
diff
changeset
|
116 |
912
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
117 # no client connection close with response on non-cacheable HEAD requests |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
118 # see 545b5e4d83b2 in nginx for detailed explanation |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
119 |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
120 my $s = http(<<EOF, start => 1); |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
121 HEAD /big.html?e=1 HTTP/1.1 |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
122 Host: localhost |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
123 |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
124 EOF |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
125 |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
126 my $r = http_get('/t.html', socket => $s); |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
127 |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
128 like($r, qr/Connection: keep-alive/, 'non-cacheable head - keepalive'); |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
129 like($r, qr/SEE-THIS/, 'non-cacheable head - second'); |
03e6f4bd35fd
Tests: no client connection close with non-cacheable HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
749
diff
changeset
|
130 |
74
3afbba94c8eb
Tests: basic proxy_cache tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 ############################################################################### |
140
3f246a1be2b0
Tests: unfinished responses shouldn't be cached.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
132 |
145
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
133 sub http_get_range { |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
134 my ($url, $extra) = @_; |
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
135 return http(<<EOF); |
145
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
136 GET $url HTTP/1.1 |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
137 Host: localhost |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
138 Connection: close |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
139 $extra |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
140 |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
141 EOF |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
142 } |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
143 |
2ea7cd95ff05
Tests: basic tests for range requests from cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
140
diff
changeset
|
144 ############################################################################### |