Mercurial > hg > nginx-tests
comparison h2_request_body.t @ 1091:a5e428f4440d
Tests: added request body buffering test for requests without body.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 12 Dec 2016 10:51:33 +0300 |
parents | efccab043dd3 |
children | 124322e9accd |
comparison
equal
deleted
inserted
replaced
1090:9d6a0dbb889a | 1091:a5e428f4440d |
---|---|
21 ############################################################################### | 21 ############################################################################### |
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(42); | 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(43); |
27 | 27 |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | 28 $t->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
42 listen 127.0.0.1:8081; | 42 listen 127.0.0.1:8081; |
43 server_name localhost; | 43 server_name localhost; |
44 | 44 |
45 location / { | 45 location / { |
46 add_header X-Length $http_content_length; | 46 add_header X-Length $http_content_length; |
47 } | |
48 location /off/ { | |
49 proxy_pass http://127.0.0.1:8081/; | |
50 add_header X-Body-File $request_body_file; | |
47 } | 51 } |
48 location /proxy2/ { | 52 location /proxy2/ { |
49 add_header X-Body $request_body; | 53 add_header X-Body $request_body; |
50 add_header X-Body-File $request_body_file; | 54 add_header X-Body-File $request_body_file; |
51 client_body_in_file_only on; | 55 client_body_in_file_only on; |
420 | 424 |
421 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 425 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
422 is($frame->{headers}->{':status'}, 413, | 426 is($frame->{headers}->{':status'}, 413, |
423 'request body without content-length many pad - limited'); | 427 'request body without content-length many pad - limited'); |
424 | 428 |
429 # absent request body is not buffered with client_body_in_file_only off | |
430 # see e02f1977846b for details | |
431 | |
432 $s = Test::Nginx::HTTP2->new(); | |
433 $sid = $s->new_stream({ path => '/off/t.html' }); | |
434 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
435 | |
436 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
437 is($frame->{headers}->{'x-body-file'}, undef, 'no request body in file'); | |
438 | |
425 ############################################################################### | 439 ############################################################################### |
426 | 440 |
427 sub read_body_file { | 441 sub read_body_file { |
428 my ($path) = @_; | 442 my ($path) = @_; |
429 open FILE, $path or return "$!"; | 443 open FILE, $path or return "$!"; |