comparison h2.t @ 1272:01010d9021b8

Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 29 Jan 2018 15:14:18 +0300
parents 766bcbb632ee
children d800b5ca9783
comparison
equal deleted inserted replaced
1271:6ca8b38f63b6 1272:01010d9021b8
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(144); 29 ->plan(147);
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
750 750
751 @data = grep { $_->{type} eq "DATA" } @$frames; 751 @data = grep { $_->{type} eq "DATA" } @$frames;
752 $sum = eval join '+', map { $_->{length} } @data; 752 $sum = eval join '+', map { $_->{length} } @data;
753 is($sum, 2**16 + 80, 'iws - increased'); 753 is($sum, 2**16 + 80, 'iws - increased');
754 754
755 # INITIAL_WINDOW_SIZE duplicate settings
756
757 # 6.5. SETTINGS
758 # Each parameter in a SETTINGS frame replaces any existing value for
759 # that parameter. Parameters are processed in the order in which they
760 # appear, and a receiver of a SETTINGS frame does not need to maintain
761 # any state other than the current value of its parameters. Therefore,
762 # the value of a SETTINGS parameter is the last value that is seen by a
763 # receiver.
764
765 $s = Test::Nginx::HTTP2->new();
766 $s->h2_window(2**17);
767
768 $sid = $s->new_stream({ path => '/t1.html' });
769
770 $frames = $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]);
771 @data = grep { $_->{type} eq "DATA" } @$frames;
772 $sum = eval join '+', map { $_->{length} } @data;
773 is($sum, 2**16 - 1, 'iws duplicate - default stream window');
774
775 TODO: {
776 local $TODO = 'not yet';
777
778 # this should effect in extra stream window octect
779 # $s->h2_settings(0, 0x4 => 42, 0x4 => 2**16);
780 {
781 local $SIG{PIPE} = 'IGNORE';
782 syswrite($s->{socket}, pack("x2C2x5nNnN", 12, 0x4, 4, 42, 4, 2**16));
783 }
784
785 $frames = $s->read(all => [{ sid => $sid, length => 1 }]);
786 @data = grep { $_->{type} eq "DATA" } @$frames;
787 $sum = eval join '+', map { $_->{length} } @data;
788 is($sum, 1, 'iws duplicate - updated stream window');
789
790 # yet more octets to finish receiving the response
791
792 $s->h2_settings(0, 0x4 => 2**16 + 80);
793
794 $frames = $s->read(all => [{ sid => $sid, length => 80 }]);
795 @data = grep { $_->{type} eq "DATA" } @$frames;
796 $sum = eval join '+', map { $_->{length} } @data;
797 is($sum, 80, 'iws duplicate - updated stream window 2');
798
799 }
800
755 # probe for negative available space in a flow control window 801 # probe for negative available space in a flow control window
756 802
757 # 6.9.2. Initial Flow-Control Window Size 803 # 6.9.2. Initial Flow-Control Window Size
758 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available 804 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available
759 # space in a flow-control window to become negative. A sender MUST 805 # space in a flow-control window to become negative. A sender MUST