comparison proxy_force_ranges.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 196d33c2bb45
children 97c8280de681
comparison
equal deleted inserted replaced
1210:3ca5b0081bc6 1211:0c15ba7d19b3
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(4) 26 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(6)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
45 45
46 location / { 46 location / {
47 proxy_pass http://127.0.0.1:8081; 47 proxy_pass http://127.0.0.1:8081;
48 } 48 }
49 49
50 location /proxy/ {
51 proxy_pass http://127.0.0.1:8081/;
52 proxy_force_ranges on;
53 }
54
50 location /cache/ { 55 location /cache/ {
51 proxy_pass http://127.0.0.1:8081/; 56 proxy_pass http://127.0.0.1:8081/;
52 proxy_cache NAME; 57 proxy_cache NAME;
53 proxy_cache_valid 200 1m; 58 proxy_cache_valid 200 1m;
54 59
60 listen 127.0.0.1:8081; 65 listen 127.0.0.1:8081;
61 server_name localhost; 66 server_name localhost;
62 67
63 location / { 68 location / {
64 max_ranges 0; 69 max_ranges 0;
70 add_header Last-Modified "Mon, 28 Sep 1970 06:00:00 GMT";
71 add_header ETag '"59a5401c-8"';
65 } 72 }
66 } 73 }
67 } 74 }
68 75
69 EOF 76 EOF
83 like(http_get_range('/cache/t.html', 'Range: bytes=4-'), qr/^THIS/m, 90 like(http_get_range('/cache/t.html', 'Range: bytes=4-'), qr/^THIS/m,
84 'cached range'); 91 'cached range');
85 like(http_get_range('/cache/t.html', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms, 92 like(http_get_range('/cache/t.html', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms,
86 'cached multipart range'); 93 'cached multipart range');
87 94
95 # If-Range HTTP-date request
96
97 TODO: {
98 local $TODO = 'not yet' unless $t->has_version('1.13.5');
99
100 like(http_get_range('/proxy/t.html',
101 "Range: bytes=4-\nIf-Range: Mon, 28 Sep 1970 06:00:00 GMT"),
102 qr/^THIS/m, 'if-range last-modified proxy');
103
104 }
105
106 # If-Range entity-tag request
107
108 like(http_get_range('/proxy/t.html',
109 "Range: bytes=4-\nIf-Range: \"59a5401c-8\""),
110 qr/^THIS/m, 'if-range etag proxy');
111
88 ############################################################################### 112 ###############################################################################
89 113
90 sub http_get_range { 114 sub http_get_range {
91 my ($url, $extra) = @_; 115 my ($url, $extra) = @_;
92 return http(<<EOF); 116 return http(<<EOF);