Mercurial > hg > nginx-tests
diff perl.t @ 1152:8241ebbe753d
Tests: added perl header_out content-length tests with ranges.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 24 Mar 2017 15:25:46 +0300 |
parents | 882267679006 |
children | a69de1aba1ad |
line wrap: on
line diff
--- a/perl.t Tue Mar 21 17:38:37 2017 +0300 +++ b/perl.t Fri Mar 24 15:25:46 2017 +0300 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http perl rewrite/)->plan(13) +my $t = Test::Nginx->new()->has(qw/http perl rewrite/)->plan(16) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -65,6 +65,25 @@ }'; } + location /range { + perl 'sub { + use warnings; + use strict; + + my $r = shift; + + $r->header_out("Content-Length", "42"); + $r->allow_ranges(); + $r->send_http_header("text/plain"); + + return OK if $r->header_only; + + $r->print("x" x 42); + + return OK; + }'; + } + location /body { perl 'sub { use warnings; @@ -136,6 +155,24 @@ . 'Host: localhost' . CRLF . CRLF ), qr/xff: foo1, foo2/, 'perl header_in xff2'); +# headers_out content-length tests with range filter + +like(http_get('/range'), qr/Content-Length: 42.*^x{42}$/ms, + 'perl header_out content-length'); + +like(http( + 'GET /range HTTP/1.0' . CRLF + . 'Host: localhost' . CRLF + . 'Range: bytes=0-1' . CRLF . CRLF +), qr/Content-Length: 2.*^xx$/ms, 'perl header_out content-length range'); + +like(http( + 'GET /range HTTP/1.0' . CRLF + . 'Host: localhost' . CRLF + . 'Range: bytes=0-1,3-5' . CRLF . CRLF +), qr/Content-Length: (?!42).*^xx\x0d.*^xxx\x0d/ms, + 'perl header_out content-length multipart'); + # various request body tests like(http(