Mercurial > hg > nginx-tests
comparison h2.t @ 767:fc846cf75c34
Tests: added HTTP/2 tests for malformed request body length.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 28 Oct 2015 00:11:46 +0300 |
parents | a764054d457f |
children | 5fd4f459e0d9 |
comparison
equal
deleted
inserted
replaced
766:a764054d457f | 767:fc846cf75c34 |
---|---|
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(282); | 35 ->has_daemon('openssl')->plan(284); |
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 |
1395 { path => '/proxy2/t2.html', body => 'TEST', body_split => [2] }); | 1395 { path => '/proxy2/t2.html', body => 'TEST', body_split => [2] }); |
1396 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | 1396 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
1397 | 1397 |
1398 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 1398 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
1399 is($frame->{headers}->{'x-body'}, 'TEST', 'request body in multiple frames'); | 1399 is($frame->{headers}->{'x-body'}, 'TEST', 'request body in multiple frames'); |
1400 | |
1401 # malformed request body length not equal to content-length | |
1402 | |
1403 $sess = new_session(); | |
1404 $sid = new_stream($sess, | |
1405 { path => '/proxy2/t2.html', body => 'TEST', headers => [ | |
1406 { name => ':method', value => 'GET', mode => 0 }, | |
1407 { name => ':scheme', value => 'http', mode => 0 }, | |
1408 { name => ':path', value => '/client_max_body_size', mode => 1 }, | |
1409 { name => ':authority', value => 'localhost', mode => 1 }, | |
1410 { name => 'content-length', value => '5', mode => 1 }]}); | |
1411 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1412 | |
1413 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1414 is($frame->{headers}->{':status'}, 400, 'request body less than content-length'); | |
1415 | |
1416 $sid = new_stream($sess, | |
1417 { path => '/proxy2/t2.html', body => 'TEST', headers => [ | |
1418 { name => ':method', value => 'GET', mode => 0 }, | |
1419 { name => ':scheme', value => 'http', mode => 0 }, | |
1420 { name => ':path', value => '/client_max_body_size', mode => 1 }, | |
1421 { name => ':authority', value => 'localhost', mode => 1 }, | |
1422 { name => 'content-length', value => '3', mode => 1 }]}); | |
1423 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
1424 | |
1425 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
1426 is($frame->{headers}->{':status'}, 400, 'request body more than content-length'); | |
1400 | 1427 |
1401 # client_max_body_size | 1428 # client_max_body_size |
1402 | 1429 |
1403 $sess = new_session(); | 1430 $sess = new_session(); |
1404 $sid = new_stream($sess, { path => '/client_max_body_size/t2.html', | 1431 $sid = new_stream($sess, { path => '/client_max_body_size/t2.html', |