Mercurial > hg > nginx-tests
comparison slice.t @ 1582:ab13e2744d05
Tests: added slice filter test for original Accept-Ranges.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 10 Jul 2020 12:19:37 +0300 |
parents | 97c8280de681 |
children | 5ac6efbe5552 |
comparison
equal
deleted
inserted
replaced
1581:463d6863d360 | 1582:ab13e2744d05 |
---|---|
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(76); | 26 ->plan(79); |
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 |
106 } | 106 } |
107 | 107 |
108 server { | 108 server { |
109 listen 127.0.0.1:8081; | 109 listen 127.0.0.1:8081; |
110 server_name localhost; | 110 server_name localhost; |
111 | |
112 add_header Accept-Ranges bytes; | |
111 | 113 |
112 location / { | 114 location / { |
113 if ($http_range = "") { | 115 if ($http_range = "") { |
114 set $limit_rate 100; | 116 set $limit_rate 100; |
115 } | 117 } |
126 | 128 |
127 my $r; | 129 my $r; |
128 | 130 |
129 like(http_get('/cache/nx'), qr/ 404 /, 'not found'); | 131 like(http_get('/cache/nx'), qr/ 404 /, 'not found'); |
130 like(http_get('/cache/t'), qr/ 200 .*0123456789abcdef$/ms, 'no range'); | 132 like(http_get('/cache/t'), qr/ 200 .*0123456789abcdef$/ms, 'no range'); |
133 | |
134 $r = get('/proxy/t', 'Range: bytes=3-4'); | |
135 like($r, qr/ 206 /, 'proxy - 206 partial reply'); | |
136 like($r, qr/^34$/m, 'proxy - correct content'); | |
137 | |
138 TODO: { | |
139 local $TODO = 'not yet' unless $t->has_version('1.19.2'); | |
140 | |
141 unlike($r, qr/Accept-Ranges/, 'proxy - no original accept-ranges'); | |
142 | |
143 } | |
131 | 144 |
132 $r = get('/cache/t?single', "Range: bytes=0-0"); | 145 $r = get('/cache/t?single', "Range: bytes=0-0"); |
133 like($r, qr/ 206 /, 'single - 206 partial reply'); | 146 like($r, qr/ 206 /, 'single - 206 partial reply'); |
134 like($r, qr/^0$/m, 'single - correct content'); | 147 like($r, qr/^0$/m, 'single - correct content'); |
135 like($r, qr/Status: MISS/m, 'single - cache status'); | 148 like($r, qr/Status: MISS/m, 'single - cache status'); |