Mercurial > hg > nginx-tests
changeset 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 | c6b1430afc66 |
files | range.t |
diffstat | 1 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/range.t +++ b/range.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http charset/)->plan(35); +my $t = Test::Nginx->new()->has(qw/http charset/)->plan(41); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -124,7 +124,26 @@ like($t1, qr/^X099XXXXXX\x0d?$/m, 'multi like($t1, qr/X001XXXXXX\x0d?$/m, 'multipart big - content 10-19'); like(http_get_range('/t1.html', 'Range: bytes=100000-'), qr/416/, - 'not satisfiable'); + 'not satisfiable - too big first byte pos'); +like(http_get_range('/t1.html', 'Range: bytes=alpha'), qr/416/, + 'not satisfiable - alpha in first byte pos'); +like(http_get_range('/t1.html', 'Range: bytes=10-alpha'), qr/416/, + 'not satisfiable - alpha in last byte pos'); +like(http_get_range('/t1.html', 'Range: bytes=10'), qr/416/, + 'not satisfiable - no hyphen'); +like(http_get_range('/t1.html', 'Range: bytes=10-11 12-'), qr/416/, + 'not satisfiable - no comma'); + +# last-byte-pos is taken to be equal to one less than the current length +# of the entity-body in bytes -- rfc2616 sec 14.35. + +like(http_get_range('/t1.html', 'Range: bytes=0-10001'), qr/206/, + 'satisfiable - last byte pos adjusted'); + +# total size of all ranges is greater than source response size + +like(http_get_range('/t1.html', 'Range: bytes=0-10001, 0-0'), qr/200/, + 'not satisfiable - malicious byte ranges'); like(http_get_range('/t3.html', 'Range: bytes=0-9, -10'), qr/206/, 'max_ranges not reached');