Mercurial > hg > nginx-tests
comparison h2.t @ 776:3fc382902cba
Tests: added HTTP/2 test for request body delayed in limit_req.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 05 Nov 2015 15:43:40 +0300 |
parents | cab9f60e561e |
children | ca2db52ae97f |
comparison
equal
deleted
inserted
replaced
775:a6764c2a9f12 | 776:3fc382902cba |
---|---|
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; | 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; | 31 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
32 | 32 |
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) | 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) |
34 ->has(qw/limit_conn rewrite realip shmem/) | 34 ->has(qw/limit_conn rewrite realip shmem/) |
35 ->has_daemon('openssl')->plan(284); | 35 ->has_daemon('openssl')->plan(286); |
36 | 36 |
37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL | 37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL |
38 | 38 |
39 $t->todo_alerts(); | 39 $t->todo_alerts(); |
40 | 40 |
50 http { | 50 http { |
51 %%TEST_GLOBALS_HTTP%% | 51 %%TEST_GLOBALS_HTTP%% |
52 | 52 |
53 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; | 53 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; |
54 limit_conn_zone $binary_remote_addr zone=conn:1m; | 54 limit_conn_zone $binary_remote_addr zone=conn:1m; |
55 limit_req_zone $binary_remote_addr zone=req:1m rate=1r/s; | |
55 | 56 |
56 server { | 57 server { |
57 listen 127.0.0.1:8080 http2; | 58 listen 127.0.0.1:8080 http2; |
58 listen 127.0.0.1:8081; | 59 listen 127.0.0.1:8081; |
59 listen 127.0.0.1:8082 proxy_protocol http2; | 60 listen 127.0.0.1:8082 proxy_protocol http2; |
140 } | 141 } |
141 location /proxy2/ { | 142 location /proxy2/ { |
142 add_header X-Body "$request_body"; | 143 add_header X-Body "$request_body"; |
143 proxy_pass http://127.0.0.1:8081/; | 144 proxy_pass http://127.0.0.1:8081/; |
144 } | 145 } |
146 location /proxy_limit_req/ { | |
147 add_header X-Body $request_body; | |
148 proxy_pass http://127.0.0.1:8081/; | |
149 limit_req zone=req burst=2; | |
150 } | |
145 location /cache/ { | 151 location /cache/ { |
146 proxy_pass http://127.0.0.1:8081/; | 152 proxy_pass http://127.0.0.1:8081/; |
147 proxy_cache NAME; | 153 proxy_cache NAME; |
148 proxy_cache_valid 1m; | 154 proxy_cache_valid 1m; |
149 } | 155 } |
1395 { path => '/proxy2/t2.html', body => 'TEST', body_split => [2] }); | 1401 { path => '/proxy2/t2.html', body => 'TEST', body_split => [2] }); |
1396 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | 1402 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
1397 | 1403 |
1398 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 1404 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
1399 is($frame->{headers}->{'x-body'}, 'TEST', 'request body in multiple frames'); | 1405 is($frame->{headers}->{'x-body'}, 'TEST', 'request body in multiple frames'); |
1406 | |
1407 # request body delayed in limit_req | |
1408 | |
1409 $sess = new_session(); | |
1410 $sid = new_stream($sess, { path => '/proxy_limit_req/', body => 'TEST' }); | |
1411 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1412 | |
1413 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1414 is($frame->{headers}->{'x-body'}, 'TEST', 'request body - limit req'); | |
1415 | |
1416 SKIP: { | |
1417 skip 'leaves coredump', 1 unless $t->has_version('1.9.7'); | |
1418 | |
1419 $sid = new_stream($sess, { path => '/proxy_limit_req/', body => 'TEST2' }); | |
1420 select undef, undef, undef, 1.1; | |
1421 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1422 | |
1423 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1424 is($frame->{headers}->{'x-body'}, 'TEST2', 'request body - limit req 2'); | |
1425 | |
1426 } | |
1400 | 1427 |
1401 # malformed request body length not equal to content-length | 1428 # malformed request body length not equal to content-length |
1402 | 1429 |
1403 $sess = new_session(); | 1430 $sess = new_session(); |
1404 $sid = new_stream($sess, | 1431 $sid = new_stream($sess, |