Mercurial > hg > nginx-tests
comparison h2.t @ 651:9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 18 Aug 2015 18:10:23 +0300 |
parents | 8a2cf558b8ae |
children | 5a85ad9382a3 |
comparison
equal
deleted
inserted
replaced
650:8a2cf558b8ae | 651:9f66f0029dca |
---|---|
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(142); | 35 ->has_daemon('openssl')->plan(145); |
36 | 36 |
37 $t->write_file_expand('nginx.conf', <<'EOF'); | 37 $t->write_file_expand('nginx.conf', <<'EOF'); |
38 | 38 |
39 %%TEST_GLOBALS%% | 39 %%TEST_GLOBALS%% |
40 | 40 |
82 alias %%TESTDIR%%/t2.html; | 82 alias %%TESTDIR%%/t2.html; |
83 add_header X-PP $remote_addr; | 83 add_header X-PP $remote_addr; |
84 } | 84 } |
85 location /h2 { | 85 location /h2 { |
86 return 200 $http2; | 86 return 200 $http2; |
87 } | |
88 location /chunk_size { | |
89 http2_chunk_size 1; | |
90 return 200 'body'; | |
87 } | 91 } |
88 location /redirect { | 92 location /redirect { |
89 error_page 405 /; | 93 error_page 405 /; |
90 return 405; | 94 return 405; |
91 } | 95 } |
566 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | 570 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
567 is($frame->{data}, 'h2', 'http variable - alpn'); | 571 is($frame->{data}, 'h2', 'http variable - alpn'); |
568 | 572 |
569 } | 573 } |
570 | 574 |
575 # http2_chunk_size=1 | |
576 | |
577 $sess = new_session(); | |
578 $sid = new_stream($sess, { path => '/chunk_size' }); | |
579 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
580 | |
581 my @data = grep { $_->{type} eq "DATA" } @$frames; | |
582 is(@data, 4, 'chunk_size frames'); | |
583 is(join(' ', map { $_->{data} } @data), 'b o d y', 'chunk_size data'); | |
584 is(join(' ', map { $_->{flags} } @data), '0 0 0 1', 'chunk_size flags'); | |
585 | |
571 # CONTINUATION | 586 # CONTINUATION |
572 | 587 |
573 $sess = new_session(); | 588 $sess = new_session(); |
574 $sid = new_stream($sess, { continuation => 1, headers => [ | 589 $sid = new_stream($sess, { continuation => 1, headers => [ |
575 { name => ':method', value => 'HEAD', mode => 1 }, | 590 { name => ':method', value => 'HEAD', mode => 1 }, |
905 $sid = new_stream($sess, { path => '/t1.html' }); | 920 $sid = new_stream($sess, { path => '/t1.html' }); |
906 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | 921 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); |
907 | 922 |
908 # with the default http2_chunk_size, data is divided into 8 data frames | 923 # with the default http2_chunk_size, data is divided into 8 data frames |
909 | 924 |
910 my @data = grep { $_->{type} eq "DATA" } @$frames; | 925 @data = grep { $_->{type} eq "DATA" } @$frames; |
911 my $lengths = join ' ', map { $_->{length} } @data; | 926 my $lengths = join ' ', map { $_->{length} } @data; |
912 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191', | 927 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191', |
913 'iws - stream blocked on initial window size'); | 928 'iws - stream blocked on initial window size'); |
914 | 929 |
915 h2_ping($sess, 'SEE-THIS'); | 930 h2_ping($sess, 'SEE-THIS'); |