comparison h2_limit_req.t @ 905:b4e9d2d97b7a

Tests: added HTTP/2 test for request body delayed in limit_req.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 19 Apr 2016 14:26:04 +0300
parents 266e3b2e88f9
children 44f37197181f
comparison
equal deleted inserted replaced
904:cb8438c28482 905:b4e9d2d97b7a
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 rewrite limit_req/) 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite limit_req/)
27 ->plan(6); 27 ->plan(7);
28 28
29 $t->todo_alerts() unless $t->has_version('1.9.14'); 29 $t->todo_alerts() unless $t->has_version('1.9.14');
30 30
31 $t->write_file_expand('nginx.conf', <<'EOF'); 31 $t->write_file_expand('nginx.conf', <<'EOF');
32 32
78 my $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 78 my $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
79 79
80 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 80 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
81 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST', 81 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST',
82 'request body - limit req'); 82 'request body - limit req');
83
84 TODO: {
85 local $TODO = 'not yet';
86
87 $sess = new_session();
88 $sid = new_stream($sess, { path => '/proxy_limit_req/', body_more => 1 });
89 h2_body($sess, 'TEST');
90 select undef, undef, undef, 1.1;
91 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
92
93 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
94 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST',
95 'request body - limit req - limited');
96
97 }
83 98
84 # request body delayed in limit_req - with an empty DATA frame 99 # request body delayed in limit_req - with an empty DATA frame
85 # "zero size buf in output" alerts seen 100 # "zero size buf in output" alerts seen
86 101
87 $sess = new_session(); 102 $sess = new_session();
169 184
170 ############################################################################### 185 ###############################################################################
171 186
172 sub read_body_file { 187 sub read_body_file {
173 my ($path) = @_; 188 my ($path) = @_;
189 return unless $path;
174 open FILE, $path or return "$!"; 190 open FILE, $path or return "$!";
175 local $/; 191 local $/;
176 my $content = <FILE>; 192 my $content = <FILE>;
177 close FILE; 193 close FILE;
178 return $content; 194 return $content;