comparison fastcgi_request_buffering.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
comparison
equal deleted inserted replaced
544:e82bbe71f50c 545:dbf8fb0f3d30
47 server_name localhost; 47 server_name localhost;
48 48
49 client_header_buffer_size 1k; 49 client_header_buffer_size 1k;
50 fastcgi_request_buffering off; 50 fastcgi_request_buffering off;
51 fastcgi_param REQUEST_URI $request_uri; 51 fastcgi_param REQUEST_URI $request_uri;
52 fastcgi_param CONTENT_LENGTH $content_length;
52 53
53 location / { 54 location / {
54 client_body_buffer_size 2k; 55 client_body_buffer_size 2k;
55 add_header X-Body "$request_body";
56 fastcgi_pass 127.0.0.1:8081; 56 fastcgi_pass 127.0.0.1:8081;
57 } 57 }
58 location /single { 58 location /single {
59 client_body_in_single_buffer on; 59 client_body_in_single_buffer on;
60 add_header X-Body "$request_body";
61 fastcgi_pass 127.0.0.1:8081; 60 fastcgi_pass 127.0.0.1:8081;
62 } 61 }
63 location /preread { 62 location /preread {
64 fastcgi_pass 127.0.0.1:8082; 63 fastcgi_pass 127.0.0.1:8082;
65 } 64 }
81 80
82 $t->waitforsocket('127.0.0.1:8081'); 81 $t->waitforsocket('127.0.0.1:8081');
83 82
84 ############################################################################### 83 ###############################################################################
85 84
86 unlike(http_get('/'), qr/X-Body:/ms, 'no body'); 85 like(http_get('/'), qr/X-Body: \x0d\x0a?/ms, 'no body');
87 86
88 like(http_get_body('/', '0123456789'), 87 like(http_get_body('/', '0123456789'),
89 qr/X-Body: 0123456789\x0d?$/ms, 'body'); 88 qr/X-Body: 0123456789\x0d?$/ms, 'body');
90 89
91 like(http_get_body('/', '0123456789' x 128), 90 like(http_get_body('/', '0123456789' x 128),
335 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); 334 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5);
336 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, 335 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
337 $socket); 336 $socket);
338 337
339 my $count; 338 my $count;
339 my $body;
340
340 while( $request->Accept() >= 0 ) { 341 while( $request->Accept() >= 0 ) {
341 $count++; 342 $count++;
342 343 read(STDIN, $body, $ENV{'CONTENT_LENGTH'});
343 if ($ENV{REQUEST_URI} eq '/stderr') {
344 warn "sample stderr text" x 512;
345 }
346 344
347 if ($ENV{REQUEST_URI} eq '/error_page') { 345 if ($ENV{REQUEST_URI} eq '/error_page') {
348 print "Status: 404 Not Found" . CRLF . CRLF; 346 print "Status: 404 Not Found" . CRLF . CRLF;
349 next; 347 next;
350 } 348 }
351 349
352 print <<EOF; 350 print <<EOF;
353 Location: http://127.0.0.1:8080/redirect 351 Location: http://127.0.0.1:8080/redirect
354 Content-Type: text/html 352 Content-Type: text/html
353 X-Body: $body
355 354
356 SEE-THIS 355 SEE-THIS
357 $count 356 $count
358 EOF 357 EOF
359 } 358 }