comparison slice.t @ 1211:0c15ba7d19b3

Tests: If-Range tests with proxy. This covers the following cases: - slice filter and If-Range requests (ticket #1357); - If-Range requests with proxy_force_ranges;
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 29 Aug 2017 16:56:52 +0300
parents 1173800a4a19
children 766bcbb632ee
comparison
equal deleted inserted replaced
1210:3ca5b0081bc6 1211:0c15ba7d19b3
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http proxy cache fastcgi slice rewrite/) 25 my $t = Test::Nginx->new()->has(qw/http proxy cache fastcgi slice rewrite/)
26 ->plan(74); 26 ->plan(76);
27 27
28 $t->write_file_expand('nginx.conf', <<'EOF'); 28 $t->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
47 server { 47 server {
48 listen 127.0.0.1:8080; 48 listen 127.0.0.1:8080;
49 server_name localhost; 49 server_name localhost;
50 50
51 location / { } 51 location / { }
52
53 location /proxy/ {
54 slice 2;
55
56 proxy_pass http://127.0.0.1:8081/;
57
58 proxy_set_header Range $slice_range;
59 }
52 60
53 location /cache/ { 61 location /cache/ {
54 slice 2; 62 slice 2;
55 63
56 proxy_pass http://127.0.0.1:8081/; 64 proxy_pass http://127.0.0.1:8081/;
220 like(get('/cache/t?im', "If-Match: bad"), qr/ 412 /, 'im bad'); 228 like(get('/cache/t?im', "If-Match: bad"), qr/ 412 /, 'im bad');
221 229
222 $r = get('/cache/t?if', "Range: bytes=3-4\nIf-Range: $etag"); 230 $r = get('/cache/t?if', "Range: bytes=3-4\nIf-Range: $etag");
223 like($r, qr/ 206 /, 'if-range - 206 partial reply'); 231 like($r, qr/ 206 /, 'if-range - 206 partial reply');
224 like($r, qr/^34$/m, 'if-range - correct content'); 232 like($r, qr/^34$/m, 'if-range - correct content');
233
234 # respect Last-Modified from non-cacheable response with If-Range
235
236 TODO: {
237 local $TODO = 'not yet' unless $t->has_version('1.13.5');
238
239 my ($lm) = http_get('/t') =~ /Last-Modified: (.*)/;
240 $r = get('/proxy/t', "Range: bytes=3-4\nIf-Range: $lm");
241 like($r, qr/ 206 /, 'if-range last-modified proxy - 206 partial reply');
242 like($r, qr/^34$/m, 'if-range last-modified proxy - correct content');
243
244 }
225 245
226 $r = get('/cache/t?ifb', "Range: bytes=3-4\nIf-Range: bad"); 246 $r = get('/cache/t?ifb', "Range: bytes=3-4\nIf-Range: bad");
227 like($r, qr/ 200 /, 'if-range bad - 200 ok'); 247 like($r, qr/ 200 /, 'if-range bad - 200 ok');
228 like($r, qr/^0123456789abcdef$/m, 'if-range bad - correct content'); 248 like($r, qr/^0123456789abcdef$/m, 'if-range bad - correct content');
229 249