comparison h2.t @ 1184:89b4bdd1346a

Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 06 Jun 2017 18:42:35 +0300
parents 878696cb8510
children 368ab1d8ed8b
comparison
equal deleted inserted replaced
1183:878696cb8510 1184:89b4bdd1346a
24 24
25 select STDERR; $| = 1; 25 select STDERR; $| = 1;
26 select STDOUT; $| = 1; 26 select STDOUT; $| = 1;
27 27
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/) 28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/)
29 ->plan(143); 29 ->plan(144);
30 30
31 $t->write_file_expand('nginx.conf', <<'EOF'); 31 $t->write_file_expand('nginx.conf', <<'EOF');
32 32
33 %%TEST_GLOBALS%% 33 %%TEST_GLOBALS%%
34 34
59 gzip_vary on; 59 gzip_vary on;
60 alias %%TESTDIR%%/t2.html; 60 alias %%TESTDIR%%/t2.html;
61 } 61 }
62 location /frame_size { 62 location /frame_size {
63 http2_chunk_size 64k; 63 http2_chunk_size 64k;
64 alias %%TESTDIR%%/t1.html; 64 alias %%TESTDIR%%;
65 output_buffers 2 1m; 65 output_buffers 2 1m;
66 } 66 }
67 location /chunk_size { 67 location /chunk_size {
68 http2_chunk_size 1; 68 http2_chunk_size 1;
69 return 200 'body'; 69 return 200 'body';
796 is(@$frames[0]->{type}, 'DATA', 'positive window - data'); 796 is(@$frames[0]->{type}, 'DATA', 'positive window - data');
797 is(@$frames[0]->{length}, 1, 'positive window - data length'); 797 is(@$frames[0]->{length}, 1, 'positive window - data length');
798 798
799 } 799 }
800 800
801 TODO: {
802 local $TODO = 'not yet' unless $t->has_version('1.13.2');
803
804 $s = Test::Nginx::HTTP2->new();
805 $s->h2_window(2**30);
806 $s->h2_settings(0, 0x4 => 2**30);
807
808 $sid = $s->new_stream({ path => '/frame_size/tbig.html' });
809
810 sleep 1;
811 $s->h2_settings(0, 0x5 => 2**15);
812
813 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
814 $lengths = join ' ', map { $_->{length} } @$frames;
815 unlike($lengths, qr/16384 0 16384/, 'SETTINGS ack after queued DATA');
816
817 }
818
801 # ask write handler in sending large response 819 # ask write handler in sending large response
802 820
803 SKIP: { 821 SKIP: {
804 skip 'unsafe socket tests', 4 unless $ENV{TEST_NGINX_UNSAFE}; 822 skip 'unsafe socket tests', 4 unless $ENV{TEST_NGINX_UNSAFE};
805 823
843 } 861 }
844 862
845 # SETTINGS_MAX_FRAME_SIZE 863 # SETTINGS_MAX_FRAME_SIZE
846 864
847 $s = Test::Nginx::HTTP2->new(); 865 $s = Test::Nginx::HTTP2->new();
848 $sid = $s->new_stream({ path => '/frame_size' }); 866 $sid = $s->new_stream({ path => '/frame_size/t1.html' });
849 $s->h2_window(2**18, 1); 867 $s->h2_window(2**18, 1);
850 $s->h2_window(2**18); 868 $s->h2_window(2**18);
851 869
852 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 870 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
853 @data = grep { $_->{type} eq "DATA" } @$frames; 871 @data = grep { $_->{type} eq "DATA" } @$frames;
854 is($data[0]->{length}, 2**14, 'max frame size - default'); 872 is($data[0]->{length}, 2**14, 'max frame size - default');
855 873
856 $s = Test::Nginx::HTTP2->new(); 874 $s = Test::Nginx::HTTP2->new();
857 $s->h2_settings(0, 0x5 => 2**15); 875 $s->h2_settings(0, 0x5 => 2**15);
858 $sid = $s->new_stream({ path => '/frame_size' }); 876 $sid = $s->new_stream({ path => '/frame_size/t1.html' });
859 $s->h2_window(2**18, 1); 877 $s->h2_window(2**18, 1);
860 $s->h2_window(2**18); 878 $s->h2_window(2**18);
861 879
862 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 880 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
863 @data = grep { $_->{type} eq "DATA" } @$frames; 881 @data = grep { $_->{type} eq "DATA" } @$frames;
872 890
873 $s = Test::Nginx::HTTP2->new(); 891 $s = Test::Nginx::HTTP2->new();
874 $s->h2_window(2**17); 892 $s->h2_window(2**17);
875 $s->h2_settings(0, 0x4 => 42); 893 $s->h2_settings(0, 0x4 => 42);
876 894
877 $sid = $s->new_stream({ path => '/frame_size' }); 895 $sid = $s->new_stream({ path => '/frame_size/t1.html' });
878 896
879 $s->h2_settings(0, 0x4 => 2**17, 0x5 => 2**15); 897 $s->h2_settings(0, 0x4 => 2**17, 0x5 => 2**15);
880 898
881 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 899 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
882 @data = grep { $_->{type} eq "DATA" } @$frames; 900 @data = grep { $_->{type} eq "DATA" } @$frames;