Mercurial > hg > nginx-tests
diff fastcgi_request_buffering_chunked.t @ 545:dbf8fb0f3d30
Tests: fixed unbuffered request body tests.
In particular, made sure that the whole request body is read on backend.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 08 Apr 2015 20:16:40 +0300 |
parents | e7e3ced702f5 |
children | 907e89fba9c3 |
line wrap: on
line diff
--- a/fastcgi_request_buffering_chunked.t +++ b/fastcgi_request_buffering_chunked.t @@ -53,12 +53,10 @@ http { location / { client_body_buffer_size 2k; - add_header X-Body "$request_body"; fastcgi_pass 127.0.0.1:8081; } location /single { client_body_in_single_buffer on; - add_header X-Body "$request_body"; fastcgi_pass 127.0.0.1:8081; } location /preread { @@ -84,7 +82,7 @@ EOF ############################################################################### -unlike(http_get('/'), qr/X-Body:/ms, 'no body'); +like(http_get('/'), qr/X-Body: \x0d\x0a?/ms, 'no body'); like(http_get_body('/', '0123456789'), qr/X-Body: 0123456789\x0d?$/ms, 'body'); @@ -155,14 +153,18 @@ sub http_get_body { my $body = $_; "GET $uri HTTP/1.1" . CRLF . "Host: localhost" . CRLF - . "Content-Length: " . (length $body) . CRLF . CRLF - . $body + . "Transfer-Encoding: chunked" . CRLF . CRLF + . sprintf("%x", length $body) . CRLF + . $body . CRLF + . "0" . CRLF . CRLF } @_), "GET $uri HTTP/1.1" . CRLF . "Host: localhost" . CRLF . "Connection: close" . CRLF - . "Content-Length: " . (length $last) . CRLF . CRLF - . $last + . "Transfer-Encoding: chunked" . CRLF . CRLF + . sprintf("%x", length $last) . CRLF + . $last . CRLF + . "0" . CRLF . CRLF ); } @@ -378,12 +380,16 @@ sub fastcgi_daemon { $socket); my $count; + my ($body, $buf); + while( $request->Accept() >= 0 ) { $count++; + $body = ''; - if ($ENV{REQUEST_URI} eq '/stderr') { - warn "sample stderr text" x 512; - } + do { + read(STDIN, $buf, 1024); + $body .= $buf; + } while (length $buf); if ($ENV{REQUEST_URI} eq '/error_page') { print "Status: 404 Not Found" . CRLF . CRLF; @@ -393,6 +399,7 @@ sub fastcgi_daemon { print <<EOF; Location: http://127.0.0.1:8080/redirect Content-Type: text/html +X-Body: $body SEE-THIS $count