Mercurial > hg > nginx-tests
annotate slice.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 5ac6efbe5552 |
children |
rev | line source |
---|---|
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for slice filter. |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1582
diff
changeset
|
18 use Test::Nginx; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy cache fastcgi slice rewrite/) |
1582
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
26 ->plan(79); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
41 proxy_cache_path %%TESTDIR%%/cach3 keys_zone=NAME3:1m; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 proxy_cache_key $uri$is_args$args$slice_range; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 fastcgi_cache_path %%TESTDIR%%/cache2 keys_zone=NAME2:1m; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 fastcgi_cache_key $uri$is_args$args$slice_range; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 listen 127.0.0.1:8080; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 server_name localhost; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location / { } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
1211
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
53 location /proxy/ { |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
54 slice 2; |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
55 |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
56 proxy_pass http://127.0.0.1:8081/; |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
57 |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
58 proxy_set_header Range $slice_range; |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
59 } |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
60 |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 location /cache/ { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 slice 2; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 proxy_pass http://127.0.0.1:8081/; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 proxy_cache NAME; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 proxy_set_header Range $slice_range; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 proxy_cache_valid 200 206 1h; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 add_header X-Cache-Status $upstream_cache_status; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 location /fastcgi { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 slice 2; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
78 fastcgi_pass 127.0.0.1:8082; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 fastcgi_cache NAME2; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 fastcgi_param Range $slice_range; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 fastcgi_cache_valid 200 206 1h; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 fastcgi_force_ranges on; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 add_header X-Cache-Status $upstream_cache_status; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 } |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
90 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
91 location /cache-redirect { |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
92 error_page 404 = @fallback; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
93 } |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
94 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
95 location @fallback { |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
96 slice 2; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
97 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
98 proxy_pass http://127.0.0.1:8081/t$is_args$args; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
99 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
100 proxy_cache NAME3; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
101 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
102 proxy_set_header Range $slice_range; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
103 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
104 proxy_cache_valid 200 206 1h; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
105 } |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
109 listen 127.0.0.1:8081; |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 server_name localhost; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
1582
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
112 add_header Accept-Ranges bytes; |
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
113 |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
114 location / { |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
115 if ($http_range = "") { |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
116 set $limit_rate 100; |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
117 } |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
118 } |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 EOF |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
124 $t->write_file('t', '0123456789abcdef'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $t->run(); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 ############################################################################### |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 my $r; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 like(http_get('/cache/nx'), qr/ 404 /, 'not found'); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
132 like(http_get('/cache/t'), qr/ 200 .*0123456789abcdef$/ms, 'no range'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
1582
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
134 $r = get('/proxy/t', 'Range: bytes=3-4'); |
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
135 like($r, qr/ 206 /, 'proxy - 206 partial reply'); |
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
136 like($r, qr/^34$/m, 'proxy - correct content'); |
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
137 unlike($r, qr/Accept-Ranges/, 'proxy - no original accept-ranges'); |
ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
138 |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 $r = get('/cache/t?single', "Range: bytes=0-0"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 like($r, qr/ 206 /, 'single - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 like($r, qr/^0$/m, 'single - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 like($r, qr/Status: MISS/m, 'single - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $r = get('/cache/t?single', "Range: bytes=0-0"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 like($r, qr/ 206 /, 'single cached - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 like($r, qr/^0$/m, 'single cached - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 like($r, qr/Status: HIT/m, 'single cached - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 $r = get('/cache/t?single', "Range: bytes=1-1"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 like($r, qr/ 206 /, 'single next - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 like($r, qr/^1$/m, 'single next - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 like($r, qr/Status: HIT/m, 'single next - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 $r = get('/cache/t?single', "Range: bytes=2-2"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 like($r, qr/ 206 /, 'slice next - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 like($r, qr/^2$/m, 'slice next - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 like($r, qr/Status: MISS/m, 'slice next - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 $r = get('/cache/t?single', "Range: bytes=2-2"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 like($r, qr/ 206 /, 'slice next cached - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 like($r, qr/^2$/m, 'slice next cached - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 like($r, qr/Status: HIT/m, 'slice next cached - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 $r = get('/cache/t?median', "Range: bytes=2-2"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 like($r, qr/ 206 /, 'slice median - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 like($r, qr/^2$/m, 'slice median - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 like($r, qr/Status: MISS/m, 'slice median - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 $r = get('/cache/t?median', "Range: bytes=0-0"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 like($r, qr/ 206 /, 'before median - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 like($r, qr/^0$/m, 'before median - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 like($r, qr/Status: MISS/m, 'before median - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 # range span to multiple slices |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 $r = get('/cache/t?range', "Range: bytes=1-2"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 like($r, qr/ 206 /, 'slice range - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 like($r, qr/^12$/m, 'slice range - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 like($r, qr/Status: MISS/m, 'slice range - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 $r = get('/cache/t?range', "Range: bytes=0-0"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 like($r, qr/ 206 /, 'slice 1st - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 like($r, qr/^0$/m, 'slice 1st - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 like($r, qr/Status: HIT/m, 'slice 1st - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 $r = get('/cache/t?range', "Range: bytes=2-2"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 like($r, qr/ 206 /, 'slice 2nd - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 like($r, qr/^2$/m, 'slice 2nd - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 like($r, qr/Status: HIT/m, 'slice 2nd - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 $r = get('/cache/t?mrange', "Range: bytes=3-4"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 like($r, qr/ 206 /, 'range median - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 like($r, qr/^34$/m, 'range median - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 like($r, qr/Status: MISS/m, 'range median - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 $r = get('/cache/t?mrange', "Range: bytes=2-3"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 like($r, qr/ 206 /, 'range prev - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 like($r, qr/^23$/m, 'range prev - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 like($r, qr/Status: HIT/m, 'range prev - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 $r = get('/cache/t?mrange', "Range: bytes=4-5"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 like($r, qr/ 206 /, 'range next - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 like($r, qr/^45$/m, 'range next - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 like($r, qr/Status: HIT/m, 'range next - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 $r = get('/cache/t?first', "Range: bytes=2-"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 like($r, qr/ 206 /, 'first bytes - 206 partial reply'); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
208 like($r, qr/^23456789abcdef$/m, 'first bytes - correct content'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 like($r, qr/Status: MISS/m, 'first bytes - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 $r = get('/cache/t?first', "Range: bytes=4-"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 like($r, qr/ 206 /, 'first bytes cached - 206 partial reply'); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
213 like($r, qr/^456789abcdef$/m, 'first bytes cached - correct content'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 like($r, qr/Status: HIT/m, 'first bytes cached - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 # multiple ranges |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 # we want 206, but 200 is also fine |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 $r = get('/cache/t?many', "Range: bytes=3-3,4-4"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 like($r, qr/200 OK/, 'many - 206 partial reply'); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
221 like($r, qr/^0123456789abcdef$/m, 'many - correct content'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 $r = get('/cache/t?last', "Range: bytes=-10"); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
224 like($r, qr/206 /, 'last bytes - 206 partial reply'); |
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
225 like($r, qr/^6789abcdef$/m, 'last bytes - correct content'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 # respect not modified and range filters |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 my ($etag) = http_get('/t') =~ /ETag: (.*)/; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 like(get('/cache/t?inm', "If-None-Match: $etag"), qr/ 304 /, 'inm'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 like(get('/cache/t?inm', "If-None-Match: bad"), qr/ 200 /, 'inm bad'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 like(get('/cache/t?im', "If-Match: $etag"), qr/ 200 /, 'im'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 like(get('/cache/t?im', "If-Match: bad"), qr/ 412 /, 'im bad'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 $r = get('/cache/t?if', "Range: bytes=3-4\nIf-Range: $etag"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 like($r, qr/ 206 /, 'if-range - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 like($r, qr/^34$/m, 'if-range - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 |
1211
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
241 # respect Last-Modified from non-cacheable response with If-Range |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
242 |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
243 my ($lm) = http_get('/t') =~ /Last-Modified: (.*)/; |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
244 $r = get('/proxy/t', "Range: bytes=3-4\nIf-Range: $lm"); |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
245 like($r, qr/ 206 /, 'if-range last-modified proxy - 206 partial reply'); |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
246 like($r, qr/^34$/m, 'if-range last-modified proxy - correct content'); |
0c15ba7d19b3
Tests: If-Range tests with proxy.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1129
diff
changeset
|
247 |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 $r = get('/cache/t?ifb', "Range: bytes=3-4\nIf-Range: bad"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 like($r, qr/ 200 /, 'if-range bad - 200 ok'); |
1007
174e900c00dc
Tests: adjusted slice.t to test with various range header lengths.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
250 like($r, qr/^0123456789abcdef$/m, 'if-range bad - correct content'); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 # first slice isn't known |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 $r = get('/cache/t?skip', "Range: bytes=6-7\nIf-Range: $etag"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 like($r, qr/ 206 /, 'if-range skip slice - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
256 like($r, qr/^67$/m, 'if-range skip slice - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 $r = get('/cache/t?skip', "Range: bytes=6-7\nIf-Range: $etag"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 like($r, qr/ 206 /, 'if-range skip slice - cached - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 like($r, qr/^67$/m, 'if-range skip slice - cached - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 like($r, qr/HIT/, 'if-range skip bytes - cached - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 $r = get('/cache/t?skip', "Range: bytes=2-3"); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
264 like($r, qr/ 206 /, 'if-range skip slice - skipped - 206 partial reply'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
265 like($r, qr/^23$/m, 'if-range skip slice - skipped - correct content'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
266 like($r, qr/MISS/, 'if-range skip bytes - skipped - cache status'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 SKIP: { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 eval { require FCGI; }; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 skip 'FCGI not installed', 5 if $@; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 skip 'win32', 5 if $^O eq 'MSWin32'; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
273 $t->run_daemon(\&fastcgi_daemon); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
274 $t->waitforsocket('127.0.0.1:' . port(8082)); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
275 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 like(http_get('/fastcgi'), qr/200 OK.*MISS.*^012345678$/ms, 'fastcgi'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
277 like(http_get('/fastcgi'), qr/200 OK.*HIT.*^012345678$/ms, |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 'fastcgi cached'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 like(get("/fastcgi?1", "Range: bytes=0-0"), qr/ 206 .*MISS.*^0$/ms, |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 'fastcgi slice'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 like(get("/fastcgi?1", "Range: bytes=1-1"), qr/ 206 .*HIT.*^1$/ms, |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
283 'fastcgi slice cached'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
284 like(get("/fastcgi?1", "Range: bytes=2-2"), qr/ 206 .*MISS.*^2$/ms, |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
285 'fastcgi slice next'); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
286 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
287 |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
288 # slicing in named location |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
289 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1211
diff
changeset
|
290 $r = http_get('/cache-redirect'); |
1129
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
291 |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
292 like($r, qr/ 200 .*^0123456789abcdef$/ms, 'in named location'); |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
293 is(scalar @{[ glob $t->testdir() . '/cach3/*' ]}, 8, |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
294 'in named location - cache entries'); |
1173800a4a19
Tests: added slice filter tests in named location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
295 |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
296 ############################################################################### |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
297 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 sub get { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 my ($url, $extra) = @_; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 return http(<<EOF); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
301 GET $url HTTP/1.1 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
302 Host: localhost |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
303 Connection: close |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
304 $extra |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
305 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
306 EOF |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
307 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
308 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
309 ############################################################################### |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
310 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
311 sub fastcgi_daemon { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
312 my $socket = FCGI::OpenSocket('127.0.0.1:' . port(8082), 5); |
796
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
313 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 $socket); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
315 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
316 my $body = '012345678'; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
317 my $len = length($body); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
318 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
319 while ($request->Accept() >= 0) { |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
320 my ($start, $stop) = $ENV{Range} =~ /bytes=(\d+)-(\d+)/; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
321 my $body = substr($body, $start, ($stop - $start) + 1); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
322 $stop = $len - 1 if $stop > $len - 1; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
323 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
324 print <<EOF; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
325 Status: 206 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
326 Content-Type: text/html |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
327 Content-Range: bytes $start-$stop/$len |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
328 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
329 EOF |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
330 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
331 print $body; |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
332 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
333 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
334 FCGI::CloseSocket($socket); |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
335 } |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
336 |
92375c379a0a
Tests: slice filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
337 ############################################################################### |