comparison h2.t @ 830:3d12316e6f41

Tests: added HTTP/2 tests for client header and body timeouts.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 27 Jan 2016 18:44:18 +0300
parents 5c003c3b8e9e
children c384a2e53c1b
comparison
equal deleted inserted replaced
829:5c003c3b8e9e 830:3d12316e6f41
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(296); 35 ->has_daemon('openssl')->plan(300);
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
244 listen 127.0.0.1:8091 http2; 244 listen 127.0.0.1:8091 http2;
245 server_name localhost; 245 server_name localhost;
246 246
247 send_timeout 1s; 247 send_timeout 1s;
248 } 248 }
249
250 server {
251 listen 127.0.0.1:8093 http2;
252 server_name localhost;
253
254 client_header_timeout 1s;
255 client_body_timeout 1s;
256
257 location /proxy/ {
258 proxy_pass http://127.0.0.1:8081/;
259 }
260 }
249 } 261 }
250 262
251 EOF 263 EOF
252 264
253 $t->write_file('openssl.conf', <<EOF); 265 $t->write_file('openssl.conf', <<EOF);
1491 1503
1492 undef $sess; 1504 undef $sess;
1493 1505
1494 } 1506 }
1495 1507
1508 # partial request header frame received (field split),
1509 # the rest of frame is received after client header timeout
1510
1511 TODO: {
1512 local $TODO = 'not yet';
1513
1514 $sess = new_session(8093);
1515 $sid = new_stream($sess, { path => '/t2.html', split => [35],
1516 split_delay => 2.1 });
1517 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
1518
1519 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
1520 ok($frame, 'client header timeout');
1521
1522 }
1523
1524 h2_ping($sess, 'SEE-THIS');
1525 $frames = h2_read($sess, all => [{ type => 'PING' }]);
1526
1527 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
1528 ok($frame, 'client header timeout - PING');
1529
1530 # partial request body data frame received, the rest is after body timeout
1531
1532 TODO: {
1533 local $TODO = 'not yet';
1534
1535 $sess = new_session(8093);
1536 $sid = new_stream($sess, { path => '/proxy/t2.html', body => 'TEST',
1537 split => [67], split_delay => 2.1 });
1538 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
1539
1540 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
1541 ok($frame, 'client body timeout');
1542
1543 }
1544
1545 h2_ping($sess, 'SEE-THIS');
1546 $frames = h2_read($sess, all => [{ type => 'PING' }]);
1547
1548 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
1549 ok($frame, 'client body timeout - PING');
1550
1496 # malformed request body length not equal to content-length 1551 # malformed request body length not equal to content-length
1497 1552
1498 $sess = new_session(); 1553 $sess = new_session();
1499 $sid = new_stream($sess, 1554 $sid = new_stream($sess,
1500 { path => '/proxy2/t2.html', body => 'TEST', headers => [ 1555 { path => '/proxy2/t2.html', body => 'TEST', headers => [
2979 # graceful shutdown waiting on incomplete request body DATA frames 3034 # graceful shutdown waiting on incomplete request body DATA frames
2980 3035
2981 my $grace3 = new_session(8090); 3036 my $grace3 = new_session(8090);
2982 $sid = new_stream($grace3, { path => '/proxy2/t2.html', body => 'TEST', 3037 $sid = new_stream($grace3, { path => '/proxy2/t2.html', body => 'TEST',
2983 body_split => [ 2 ], split => [ 67 ], abort => 1 }); 3038 body_split => [ 2 ], split => [ 67 ], abort => 1 });
3039
3040 # partial request body data frame with connection close after body timeout
3041
3042 my $grace4 = new_session(8093);
3043 $sid = new_stream($grace4, { path => '/proxy/t2.html', body => 'TEST',
3044 split => [67], abort => 1 });
3045
3046 select undef, undef, undef, 1.1;
3047 undef $grace4;
2984 3048
2985 $t->stop(); 3049 $t->stop();
2986 3050
2987 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); 3051 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
2988 3052