comparison range.t @ 345:8e8636a4fe61

Tests: more range filter tests for satisfiable ranges.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 30 Sep 2013 19:07:42 +0400
parents b6d566531746
children d5bf5942a8b2
comparison
equal deleted inserted replaced
344:b6d566531746 345:8e8636a4fe61
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http charset/)->plan(35); 24 my $t = Test::Nginx->new()->has(qw/http charset/)->plan(41);
25 25
26 $t->write_file_expand('nginx.conf', <<'EOF'); 26 $t->write_file_expand('nginx.conf', <<'EOF');
27 27
28 %%TEST_GLOBALS%% 28 %%TEST_GLOBALS%%
29 29
122 like($t1, qr/X000XXXXXX/m, 'multipart big - content 0-9'); 122 like($t1, qr/X000XXXXXX/m, 'multipart big - content 0-9');
123 like($t1, qr/^X099XXXXXX\x0d?$/m, 'multipart big - content -10 aka 990-999'); 123 like($t1, qr/^X099XXXXXX\x0d?$/m, 'multipart big - content -10 aka 990-999');
124 like($t1, qr/X001XXXXXX\x0d?$/m, 'multipart big - content 10-19'); 124 like($t1, qr/X001XXXXXX\x0d?$/m, 'multipart big - content 10-19');
125 125
126 like(http_get_range('/t1.html', 'Range: bytes=100000-'), qr/416/, 126 like(http_get_range('/t1.html', 'Range: bytes=100000-'), qr/416/,
127 'not satisfiable'); 127 'not satisfiable - too big first byte pos');
128 like(http_get_range('/t1.html', 'Range: bytes=alpha'), qr/416/,
129 'not satisfiable - alpha in first byte pos');
130 like(http_get_range('/t1.html', 'Range: bytes=10-alpha'), qr/416/,
131 'not satisfiable - alpha in last byte pos');
132 like(http_get_range('/t1.html', 'Range: bytes=10'), qr/416/,
133 'not satisfiable - no hyphen');
134 like(http_get_range('/t1.html', 'Range: bytes=10-11 12-'), qr/416/,
135 'not satisfiable - no comma');
136
137 # last-byte-pos is taken to be equal to one less than the current length
138 # of the entity-body in bytes -- rfc2616 sec 14.35.
139
140 like(http_get_range('/t1.html', 'Range: bytes=0-10001'), qr/206/,
141 'satisfiable - last byte pos adjusted');
142
143 # total size of all ranges is greater than source response size
144
145 like(http_get_range('/t1.html', 'Range: bytes=0-10001, 0-0'), qr/200/,
146 'not satisfiable - malicious byte ranges');
128 147
129 like(http_get_range('/t3.html', 'Range: bytes=0-9, -10'), qr/206/, 148 like(http_get_range('/t3.html', 'Range: bytes=0-9, -10'), qr/206/,
130 'max_ranges not reached'); 149 'max_ranges not reached');
131 like(http_get_range('/t3.html', 'Range: bytes=0-9, -10, 10000-'), qr/206/, 150 like(http_get_range('/t3.html', 'Range: bytes=0-9, -10, 10000-'), qr/206/,
132 'max_ranges not reached bad range'); 151 'max_ranges not reached bad range');