Mercurial > hg > nginx-tests
annotate h2.t @ 1932:b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Previously, the test mostly passed due to a push timer scheduled for an
unrelated delayed ACK, and the new path had enough data received to send
response back when the push timer fired. Otherwise, the test could fail
due to unvalidated address. Now it is fixed to perform path validation.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 21 Aug 2023 17:10:57 +0400 |
parents | 236d038dc04a |
children | 2a0a6035a1af |
rev | line source |
---|---|
646 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/2 protocol [RFC7540]. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use Socket qw/ CRLF /; | |
16 | |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
18 | |
19 use lib 'lib'; | |
20 use Test::Nginx; | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
21 use Test::Nginx::HTTP2; |
646 | 22 |
23 ############################################################################### | |
24 | |
25 select STDERR; $| = 1; | |
26 select STDOUT; $| = 1; | |
27 | |
1002
3b1ee8acc4db
Tests: added charset and gzip prerequisites in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
997
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/) |
1898
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
29 ->plan(142); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
30 |
646 | 31 $t->write_file_expand('nginx.conf', <<'EOF'); |
32 | |
33 %%TEST_GLOBALS%% | |
34 | |
35 daemon off; | |
36 | |
37 events { | |
38 } | |
39 | |
40 http { | |
41 %%TEST_GLOBALS_HTTP%% | |
42 | |
43 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 listen 127.0.0.1:8080 http2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 listen 127.0.0.1:8081; |
646 | 46 server_name localhost; |
47 | |
48 location / { | |
49 add_header X-Header X-Foo; | |
50 add_header X-Sent-Foo $http_x_foo; | |
51 add_header X-Referer $http_referer; | |
52 return 200 'body'; | |
53 } | |
54 location /t { | |
55 } | |
56 location /gzip.html { | |
57 gzip on; | |
58 gzip_min_length 0; | |
847
7de036e89770
Tests: added HTTP/2 test with gzip vary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
846
diff
changeset
|
59 gzip_vary on; |
646 | 60 alias %%TESTDIR%%/t2.html; |
61 } | |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
62 location /frame_size { |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
63 http2_chunk_size 64k; |
1184
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
64 alias %%TESTDIR%%; |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
65 output_buffers 2 1m; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
66 } |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
67 location /chunk_size { |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
68 http2_chunk_size 1; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
69 return 200 'body'; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
70 } |
646 | 71 location /redirect { |
72 error_page 405 /; | |
73 return 405; | |
74 } | |
75 location /return301 { | |
76 return 301; | |
77 } | |
78 location /return301_absolute { | |
79 return 301 text; | |
80 } | |
81 location /return301_relative { | |
82 return 301 /; | |
83 } | |
846
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
84 location /charset { |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
85 charset utf-8; |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
86 return 200; |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
87 } |
646 | 88 } |
89 | |
90 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
91 listen 127.0.0.1:8082 http2; |
646 | 92 server_name localhost; |
93 return 200 first; | |
94 } | |
95 | |
96 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
97 listen 127.0.0.1:8082 http2; |
646 | 98 server_name localhost2; |
99 return 200 second; | |
100 } | |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
101 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
102 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
103 listen 127.0.0.1:8083 http2; |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
104 server_name localhost; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
105 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
106 http2_max_concurrent_streams 1; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
107 } |
684
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
108 |
96666f621dbc
Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
680
diff
changeset
|
109 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
110 listen 127.0.0.1:8086 http2; |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
111 server_name localhost; |
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
112 |
990
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
113 send_timeout 1s; |
1651
a78eedc39484
Tests: h2.t tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1650
diff
changeset
|
114 lingering_close off; |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
115 } |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
116 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
117 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
118 listen 127.0.0.1:8087 http2; |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
119 server_name localhost; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
120 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
121 client_header_timeout 1s; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
122 client_body_timeout 1s; |
1651
a78eedc39484
Tests: h2.t tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1650
diff
changeset
|
123 lingering_close off; |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
124 |
1650
cdba06625d65
Tests: simplified testing configuration in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1649
diff
changeset
|
125 location / { } |
cdba06625d65
Tests: simplified testing configuration in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1649
diff
changeset
|
126 |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
127 location /proxy/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
128 proxy_pass http://127.0.0.1:8081/; |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
129 } |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
130 } |
646 | 131 } |
132 | |
133 EOF | |
134 | |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1898
diff
changeset
|
135 # suppress deprecation warning |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1898
diff
changeset
|
136 |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1898
diff
changeset
|
137 open OLDERR, ">&", \*STDERR; close STDERR; |
741
a2e7f5ff3aa8
Tests: hid unwanted output with old OpenSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
740
diff
changeset
|
138 $t->run(); |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1898
diff
changeset
|
139 open STDERR, ">&", \*OLDERR; |
646 | 140 |
141 # file size is slightly beyond initial window size: 2**16 + 80 bytes | |
142 | |
143 $t->write_file('t1.html', | |
144 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); | |
145 $t->write_file('tbig.html', | |
723
bc4d6e2bd031
Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
722
diff
changeset
|
146 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000))); |
646 | 147 |
148 $t->write_file('t2.html', 'SEE-THIS'); | |
149 | |
150 ############################################################################### | |
151 | |
152 # SETTINGS | |
153 | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
154 my $s = Test::Nginx::HTTP2->new(port(8080), pure => 1); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
155 my $frames = $s->read(all => [ |
646 | 156 { type => 'WINDOW_UPDATE' }, |
157 { type => 'SETTINGS'} | |
158 ]); | |
159 | |
160 my ($frame) = grep { $_->{type} eq 'WINDOW_UPDATE' } @$frames; | |
161 ok($frame, 'WINDOW_UPDATE frame'); | |
162 is($frame->{flags}, 0, 'WINDOW_UPDATE zero flags'); | |
163 is($frame->{sid}, 0, 'WINDOW_UPDATE zero sid'); | |
164 is($frame->{length}, 4, 'WINDOW_UPDATE fixed length'); | |
165 | |
166 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
167 ok($frame, 'SETTINGS frame'); | |
168 is($frame->{flags}, 0, 'SETTINGS flags'); | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
169 is($frame->{sid}, 0, 'SETTINGS stream'); |
646 | 170 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
171 $s->h2_settings(1); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
172 $s->h2_settings(0); |
646 | 173 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
174 $frames = $s->read(all => [{ type => 'SETTINGS' }]); |
646 | 175 |
176 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
177 ok($frame, 'SETTINGS frame ack'); | |
178 is($frame->{flags}, 1, 'SETTINGS flags ack'); | |
179 | |
1183
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
180 # SETTINGS - no ack on PROTOCOL_ERROR |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
181 |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
182 $s = Test::Nginx::HTTP2->new(port(8080), pure => 1); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
183 $frames = $s->read(all => [ |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
184 { type => 'WINDOW_UPDATE' }, |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
185 { type => 'SETTINGS'} |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
186 ]); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
187 |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
188 $s->h2_settings(1); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
189 $s->h2_settings(0, 0x5 => 42); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
190 |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
191 $frames = $s->read(all => [ |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
192 { type => 'SETTINGS'}, |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
193 { type => 'GOAWAY' } |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
194 ]); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
195 |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
196 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
197 is($frame, undef, 'SETTINGS PROTOCOL_ERROR - no ack'); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
198 |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
199 ($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames; |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
200 ok($frame, 'SETTINGS PROTOCOL_ERROR - GOAWAY'); |
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
201 |
646 | 202 # PING |
203 | |
1183
878696cb8510
Tests: added HTTP/2 SETTINGS test for no ack on PROTOCOL_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1182
diff
changeset
|
204 $s = Test::Nginx::HTTP2->new(); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
205 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
206 $frames = $s->read(all => [{ type => 'PING' }]); |
646 | 207 |
208 ($frame) = grep { $_->{type} eq "PING" } @$frames; | |
209 ok($frame, 'PING frame'); | |
210 is($frame->{value}, 'SEE-THIS', 'PING payload'); | |
211 is($frame->{flags}, 1, 'PING flags ack'); | |
655
75ecd26b8831
Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
654
diff
changeset
|
212 is($frame->{sid}, 0, 'PING stream'); |
646 | 213 |
759
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
214 # GOAWAY |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
215 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
216 Test::Nginx::HTTP2->new()->h2_goaway(0, 0, 5); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
217 Test::Nginx::HTTP2->new()->h2_goaway(0, 0, 5, 'foobar'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
218 Test::Nginx::HTTP2->new()->h2_goaway(0, 0, 5, 'foobar', split => [ 8, 8, 4 ]); |
759
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
219 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
220 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
221 $s->h2_goaway(0, 0, 5); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
222 $s->h2_goaway(0, 0, 5); |
759
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
223 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
224 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
225 $s->h2_goaway(0, 0, 5, 'foobar', len => 0); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
226 $frames = $s->read(all => [{ type => "GOAWAY" }]); |
759
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
227 |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
228 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
229 ok($frame, 'GOAWAY invalid length - GOAWAY frame'); |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
230 is($frame->{code}, 6, 'GOAWAY invalid length - GOAWAY FRAME_SIZE_ERROR'); |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
231 |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
232 # 6.8. GOAWAY |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
233 # An endpoint MUST treat a GOAWAY frame with a stream identifier other |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
234 # than 0x0 as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
235 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
236 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
237 $s->h2_goaway(1, 0, 5, 'foobar'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
238 $frames = $s->read(all => [{ type => "GOAWAY" }], wait => 0.5); |
759
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
239 |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
240 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
241 ok($frame, 'GOAWAY invalid stream - GOAWAY frame'); |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
242 is($frame->{code}, 1, 'GOAWAY invalid stream - GOAWAY PROTOCOL_ERROR'); |
6406eee6366c
Tests: added simple HTTP/2 tests for client GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
758
diff
changeset
|
243 |
760
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
244 # client-initiated PUSH_PROMISE, just to ensure nothing went wrong |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
245 # N.B. other implementation returns zero code, which is not anyhow regulated |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
246 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
247 $s = Test::Nginx::HTTP2->new(); |
1174
ec9ddfed9b63
Tests: handled SIGPIPE in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1108
diff
changeset
|
248 { |
ec9ddfed9b63
Tests: handled SIGPIPE in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1108
diff
changeset
|
249 local $SIG{PIPE} = 'IGNORE'; |
ec9ddfed9b63
Tests: handled SIGPIPE in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1108
diff
changeset
|
250 syswrite($s->{socket}, pack("x2C2xN", 4, 0x5, 1)); |
ec9ddfed9b63
Tests: handled SIGPIPE in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1108
diff
changeset
|
251 } |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
252 $frames = $s->read(all => [{ type => "GOAWAY" }]); |
760
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
253 |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
254 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
255 ok($frame, 'client-initiated PUSH_PROMISE - GOAWAY frame'); |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
256 is($frame->{code}, 1, 'client-initiated PUSH_PROMISE - GOAWAY PROTOCOL_ERROR'); |
4db976a91540
Tests: HTTP/2 tests for client-initiated PUSH_PROMISE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
759
diff
changeset
|
257 |
646 | 258 # GET |
259 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
260 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
261 my $sid = $s->new_stream(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
262 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 263 |
264 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
265 ok($frame, 'HEADERS frame'); | |
266 is($frame->{sid}, $sid, 'HEADERS stream'); | |
267 is($frame->{headers}->{':status'}, 200, 'HEADERS status'); | |
268 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header'); | |
269 | |
270 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
271 ok($frame, 'DATA frame'); | |
272 is($frame->{length}, length 'body', 'DATA length'); | |
273 is($frame->{data}, 'body', 'DATA payload'); | |
274 | |
275 # GET in the new stream on same connection | |
276 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
277 $sid = $s->new_stream(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
278 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 279 |
280 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
281 is($frame->{sid}, $sid, 'HEADERS stream 2'); | |
282 is($frame->{headers}->{':status'}, 200, 'HEADERS status 2'); | |
283 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header 2'); | |
284 | |
285 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
286 ok($frame, 'DATA frame 2'); | |
287 is($frame->{sid}, $sid, 'HEADERS stream 2'); | |
288 is($frame->{length}, length 'body', 'DATA length 2'); | |
289 is($frame->{data}, 'body', 'DATA payload 2'); | |
290 | |
291 # HEAD | |
292 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
293 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
294 $sid = $s->new_stream({ method => 'HEAD' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
295 $frames = $s->read(all => [{ sid => $sid, fin => 0x4 }]); |
646 | 296 |
297 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
298 is($frame->{sid}, $sid, 'HEAD - HEADERS'); | |
299 is($frame->{headers}->{':status'}, 200, 'HEAD - HEADERS status'); | |
300 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEAD - HEADERS header'); | |
301 | |
302 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
303 is($frame, undef, 'HEAD - no body'); | |
304 | |
1710
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
305 # CONNECT |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
306 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
307 TODO: { |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
308 local $TODO = 'not yet' unless $t->has_version('1.21.1'); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
309 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
310 $s = Test::Nginx::HTTP2->new(); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
311 $sid = $s->new_stream({ method => 'CONNECT' }); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
312 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
313 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
314 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
315 is($frame->{headers}->{':status'}, 405, 'CONNECT - not allowed'); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
316 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
317 } |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
318 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
319 # TRACE |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
320 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
321 $s = Test::Nginx::HTTP2->new(); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
322 $sid = $s->new_stream({ method => 'TRACE' }); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
323 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
324 |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
325 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
326 is($frame->{headers}->{':status'}, 405, 'TRACE - not allowed'); |
f3de5730bc06
Tests: CONNECT and TRACE method tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
327 |
646 | 328 # range filter |
329 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
330 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
331 $sid = $s->new_stream({ headers => [ |
646 | 332 { name => ':method', value => 'GET', mode => 0 }, |
333 { name => ':scheme', value => 'http', mode => 0 }, | |
334 { name => ':path', value => '/t1.html', mode => 1 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
335 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 336 { name => 'range', value => 'bytes=10-19', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
337 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 338 |
339 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
340 is($frame->{headers}->{':status'}, 206, 'range - HEADERS status'); | |
341 | |
342 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
343 is($frame->{length}, 10, 'range - DATA length'); | |
344 is($frame->{data}, '002XXXX000', 'range - DATA payload'); | |
345 | |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
346 # http2_chunk_size=1 |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
347 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
348 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
349 $sid = $s->new_stream({ path => '/chunk_size' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
350 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
351 |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
352 my @data = grep { $_->{type} eq "DATA" } @$frames; |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
353 is(@data, 4, 'chunk_size frames'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
354 is(join(' ', map { $_->{data} } @data), 'b o d y', 'chunk_size data'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
355 is(join(' ', map { $_->{flags} } @data), '0 0 0 1', 'chunk_size flags'); |
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
356 |
646 | 357 # CONTINUATION |
358 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
359 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
360 $sid = $s->new_stream({ continuation => 1, headers => [ |
646 | 361 { name => ':method', value => 'HEAD', mode => 1 }, |
362 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
363 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
364 { name => ':authority', value => 'localhost', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
365 $s->h2_continue($sid, { continuation => 1, headers => [ |
646 | 366 { name => 'x-foo', value => 'X-Bar', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
367 $s->h2_continue($sid, { headers => [ |
646 | 368 { name => 'referer', value => 'foo', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
369 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 370 |
371 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
372 is($frame, undef, 'CONTINUATION - fragment 1'); | |
373 | |
374 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
375 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2'); | |
376 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3'); | |
377 | |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
378 # CONTINUATION - in the middle of request header field |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
379 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
380 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
381 $sid = $s->new_stream({ continuation => [ 2, 4, 1, 5 ], headers => [ |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
382 { name => ':method', value => 'HEAD', mode => 1 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
383 { name => ':scheme', value => 'http', mode => 0 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
384 { name => ':path', value => '/', mode => 0 }, |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
385 { name => ':authority', value => 'localhost', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
386 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
699
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
387 |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
388 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
389 is($frame->{headers}->{':status'}, 200, 'CONTINUATION - in header field'); |
5768830f01c4
Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents:
698
diff
changeset
|
390 |
761
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
391 # CONTINUATION on a closed stream |
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
392 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
393 $s->h2_continue(1, { headers => [ |
761
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
394 { name => 'x-foo', value => 'X-Bar', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
395 $frames = $s->read(all => [{ sid => 1, fin => 1 }]); |
761
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
396 |
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
397 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
398 is($frame->{type}, 'GOAWAY', 'GOAWAY - CONTINUATION closed stream'); |
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
399 is($frame->{code}, 1, 'GOAWAY - CONTINUATION closed stream - PROTOCOL_ERROR'); |
01feb5d4d7a4
Tests: HTTP/2 test for CONTINUATION on a closed stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
760
diff
changeset
|
400 |
646 | 401 # frame padding |
402 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
403 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
404 $sid = $s->new_stream({ padding => 42, headers => [ |
646 | 405 { name => ':method', value => 'GET', mode => 0 }, |
406 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
407 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
408 { name => ':authority', value => 'localhost', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
409 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 410 |
411 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
412 is($frame->{headers}->{':status'}, 200, 'padding - HEADERS status'); | |
413 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
414 $sid = $s->new_stream({ headers => [ |
646 | 415 { name => ':method', value => 'GET', mode => 0 }, |
416 { name => ':scheme', value => 'http', mode => 0 }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
417 { name => ':path', value => '/', mode => 0 }, |
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
418 { name => ':authority', value => 'localhost', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
419 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 420 |
421 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
422 is($frame->{headers}->{':status'}, 200, 'padding - next stream'); | |
423 | |
821
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
424 # padding followed by CONTINUATION |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
425 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
426 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
427 $sid = $s->new_stream({ padding => 42, continuation => [ 2, 4, 1, 5 ], |
821
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
428 headers => [ |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
429 { name => ':method', value => 'GET', mode => 1 }, |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
430 { name => ':scheme', value => 'http', mode => 0 }, |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
431 { name => ':path', value => '/', mode => 0 }, |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
432 { name => ':authority', value => 'localhost', mode => 1 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
433 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
821
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
434 |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
435 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
436 is($frame->{headers}->{':status'}, 200, 'padding - CONTINUATION'); |
d75000247e1f
Tests: added HTTP/2 test for padded HEADERS with CONTINUATION.
Sergey Kandaurov <pluknet@nginx.com>
parents:
818
diff
changeset
|
437 |
646 | 438 # internal redirect |
439 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
440 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
441 $sid = $s->new_stream({ path => '/redirect' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
442 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 443 |
444 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
445 is($frame->{headers}->{':status'}, 405, 'redirect - HEADERS'); | |
446 | |
447 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
448 ok($frame, 'redirect - DATA'); | |
449 is($frame->{data}, 'body', 'redirect - DATA payload'); | |
450 | |
451 # return 301 with absolute URI | |
452 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
453 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
454 $sid = $s->new_stream({ path => '/return301_absolute' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
455 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 456 |
457 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
458 is($frame->{headers}->{':status'}, 301, 'return 301 absolute - status'); | |
459 is($frame->{headers}->{'location'}, 'text', 'return 301 absolute - location'); | |
460 | |
461 # return 301 with relative URI | |
462 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
463 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
464 $sid = $s->new_stream({ path => '/return301_relative' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
465 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 466 |
467 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
468 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status'); | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
469 is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/', |
646 | 470 'return 301 relative - location'); |
471 | |
472 # return 301 with relative URI and ':authority' request header field | |
473 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
474 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
475 $sid = $s->new_stream({ headers => [ |
646 | 476 { name => ':method', value => 'GET', mode => 0 }, |
477 { name => ':scheme', value => 'http', mode => 0 }, | |
478 { name => ':path', value => '/return301_relative', mode => 2 }, | |
479 { name => ':authority', value => 'localhost', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
480 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 481 |
482 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
483 is($frame->{headers}->{':status'}, 301, | |
484 'return 301 relative - authority - status'); | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
485 is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/', |
646 | 486 'return 301 relative - authority - location'); |
487 | |
488 # return 301 with relative URI and 'host' request header field | |
489 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
490 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
491 $sid = $s->new_stream({ headers => [ |
646 | 492 { name => ':method', value => 'GET', mode => 0 }, |
493 { name => ':scheme', value => 'http', mode => 0 }, | |
494 { name => ':path', value => '/return301_relative', mode => 2 }, | |
495 { name => 'host', value => 'localhost', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
496 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 497 |
498 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
499 is($frame->{headers}->{':status'}, 301, | |
500 'return 301 relative - host - status'); | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
501 is($frame->{headers}->{'location'}, 'http://localhost:' . port(8080) . '/', |
646 | 502 'return 301 relative - host - location'); |
503 | |
504 # virtual host | |
505 | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
506 $s = Test::Nginx::HTTP2->new(port(8082)); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
507 $sid = $s->new_stream({ headers => [ |
646 | 508 { name => ':method', value => 'GET', mode => 0 }, |
509 { name => ':scheme', value => 'http', mode => 0 }, | |
510 { name => ':path', value => '/', mode => 0 }, | |
511 { name => 'host', value => 'localhost', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
512 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 513 |
514 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
515 is($frame->{headers}->{':status'}, 200, | |
516 'virtual host - host - status'); | |
517 | |
518 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
519 is($frame->{data}, 'first', 'virtual host - host - DATA'); | |
520 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
521 $sid = $s->new_stream({ headers => [ |
646 | 522 { name => ':method', value => 'GET', mode => 0 }, |
523 { name => ':scheme', value => 'http', mode => 0 }, | |
524 { name => ':path', value => '/', mode => 0 }, | |
525 { name => ':authority', value => 'localhost', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
526 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 527 |
528 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
529 is($frame->{headers}->{':status'}, 200, | |
530 'virtual host - authority - status'); | |
531 | |
532 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
533 is($frame->{data}, 'first', 'virtual host - authority - DATA'); | |
534 | |
535 # virtual host - second | |
536 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
537 $sid = $s->new_stream({ headers => [ |
646 | 538 { name => ':method', value => 'GET', mode => 0 }, |
539 { name => ':scheme', value => 'http', mode => 0 }, | |
540 { name => ':path', value => '/', mode => 0 }, | |
541 { name => 'host', value => 'localhost2', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
542 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 543 |
544 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
545 is($frame->{headers}->{':status'}, 200, | |
546 'virtual host 2 - host - status'); | |
547 | |
548 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
549 is($frame->{data}, 'second', 'virtual host 2 - host - DATA'); | |
550 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
551 $sid = $s->new_stream({ headers => [ |
646 | 552 { name => ':method', value => 'GET', mode => 0 }, |
553 { name => ':scheme', value => 'http', mode => 0 }, | |
554 { name => ':path', value => '/', mode => 0 }, | |
555 { name => ':authority', value => 'localhost2', mode => 2 }]}); | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
556 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 557 |
558 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
559 is($frame->{headers}->{':status'}, 200, | |
560 'virtual host 2 - authority - status'); | |
561 | |
562 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
563 is($frame->{data}, 'second', 'virtual host 2 - authority - DATA'); | |
564 | |
565 # gzip tests for internal nginx version | |
566 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
567 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
568 $sid = $s->new_stream({ headers => [ |
646 | 569 { name => ':method', value => 'GET', mode => 0 }, |
570 { name => ':scheme', value => 'http', mode => 0 }, | |
571 { name => ':path', value => '/gzip.html' }, | |
653
5ad620022234
Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
652
diff
changeset
|
572 { name => ':authority', value => 'localhost', mode => 1 }, |
646 | 573 { name => 'accept-encoding', value => 'gzip' }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
574 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 575 |
576 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
577 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding'); | |
847
7de036e89770
Tests: added HTTP/2 test with gzip vary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
846
diff
changeset
|
578 is($frame->{headers}->{'vary'}, 'Accept-Encoding', 'gzip - vary'); |
646 | 579 |
580 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
581 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA'); |
646 | 582 |
846
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
583 # charset |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
584 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
585 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
586 $sid = $s->new_stream({ path => '/charset' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
587 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
846
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
588 |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
589 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
590 is($frame->{headers}->{'content-type'}, 'text/plain; charset=utf-8', 'charset'); |
9b5e1c5f0240
Tests: added HTTP/2 test with charset.
Sergey Kandaurov <pluknet@nginx.com>
parents:
845
diff
changeset
|
591 |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
592 # partial request header frame received (field split), |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
593 # the rest of frame is received after client header timeout |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
594 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
595 $s = Test::Nginx::HTTP2->new(port(8087)); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
596 $sid = $s->new_stream({ path => '/t2.html', split => [35], |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
597 split_delay => 2.1 }); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
598 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
599 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
600 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
601 ok($frame, 'client header timeout'); |
841
6a401b5fa812
Tests: check timed out HTTP/2 streams for proper RST_STREAM code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
840
diff
changeset
|
602 is($frame->{code}, 1, 'client header timeout - protocol error'); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
603 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
604 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
605 $frames = $s->read(all => [{ type => 'PING' }]); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
606 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
607 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
608 ok($frame, 'client header timeout - PING'); |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
609 |
1548
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
610 # partial request header frame received (no field split), |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
611 # the rest of frame is received after client header timeout |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
612 |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
613 $s = Test::Nginx::HTTP2->new(port(8087)); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
614 $sid = $s->new_stream({ path => '/t2.html', split => [20], split_delay => 2.1 }); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
615 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
616 |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
617 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
618 ok($frame, 'client header timeout 2'); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
619 is($frame->{code}, 1, 'client header timeout 2 - protocol error'); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
620 |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
621 $s->h2_ping('SEE-THIS'); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
622 $frames = $s->read(all => [{ type => 'PING' }]); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
623 |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
624 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames; |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
625 ok($frame, 'client header timeout 2 - PING'); |
b02d0fd71638
Tests: added HTTP/2 test for HEADERS split on field boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1465
diff
changeset
|
626 |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
627 # partial request body data frame received, the rest is after body timeout |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
628 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
629 $s = Test::Nginx::HTTP2->new(port(8087)); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
630 $sid = $s->new_stream({ path => '/proxy/t2.html', body_more => 1 }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
631 $s->h2_body('TEST', { split => [10], split_delay => 2.1 }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
632 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
633 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
634 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
635 ok($frame, 'client body timeout'); |
841
6a401b5fa812
Tests: check timed out HTTP/2 streams for proper RST_STREAM code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
840
diff
changeset
|
636 is($frame->{code}, 1, 'client body timeout - protocol error'); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
637 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
638 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
639 $frames = $s->read(all => [{ type => 'PING' }]); |
830
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
640 |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
641 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames; |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
642 ok($frame, 'client body timeout - PING'); |
3d12316e6f41
Tests: added HTTP/2 tests for client header and body timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
829
diff
changeset
|
643 |
1647
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
644 # partial request body data frame with connection close after body timeout |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
645 |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
646 $s = Test::Nginx::HTTP2->new(port(8087)); |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
647 $sid = $s->new_stream({ path => '/proxy/t2.html', body_more => 1 }); |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
648 $s->h2_body('TEST', { split => [ 12 ], abort => 1 }); |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
649 |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
650 select undef, undef, undef, 1.1; |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
651 undef $s; |
35beaf85de72
Tests: sorted h2.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1589
diff
changeset
|
652 |
852
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
653 # proxied request with logging pristine request header field (e.g., referer) |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
654 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
655 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
656 $sid = $s->new_stream({ headers => [ |
852
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
657 { name => ':method', value => 'GET' }, |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
658 { name => ':scheme', value => 'http' }, |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
659 { name => ':path', value => '/proxy2/' }, |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
660 { name => ':authority', value => 'localhost' }, |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
661 { name => 'referer', value => 'foo' }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
662 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
852
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
663 |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
664 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
665 is($frame->{headers}->{':status'}, 200, 'proxy with logging request headers'); |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
666 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
667 $sid = $s->new_stream(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
668 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
852
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
669 |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
670 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
671 ok($frame->{headers}, 'proxy with logging request headers - next'); |
e0d6ba59968f
Tests: added HTTP/2 proxy test with logging request headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
850
diff
changeset
|
672 |
646 | 673 # initial window size, client side |
674 | |
675 # 6.9.2. Initial Flow-Control Window Size | |
676 # When an HTTP/2 connection is first established, new streams are | |
677 # created with an initial flow-control window size of 65,535 octets. | |
678 # The connection flow-control window is also 65,535 octets. | |
679 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
680 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
681 $sid = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
682 $frames = $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
646 | 683 |
684 # with the default http2_chunk_size, data is divided into 8 data frames | |
685 | |
651
9f66f0029dca
Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
650
diff
changeset
|
686 @data = grep { $_->{type} eq "DATA" } @$frames; |
646 | 687 my $lengths = join ' ', map { $_->{length} } @data; |
688 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191', | |
689 'iws - stream blocked on initial window size'); | |
690 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
691 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
692 $frames = $s->read(all => [{ type => 'PING' }]); |
646 | 693 |
694 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames; | |
695 ok($frame, 'iws - PING not blocked'); | |
696 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
697 $s->h2_window(2**16, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
698 $frames = $s->read(wait => 0.2); |
646 | 699 is(@$frames, 0, 'iws - updated stream window'); |
700 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
701 $s->h2_window(2**16); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
702 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 703 |
704 @data = grep { $_->{type} eq "DATA" } @$frames; | |
705 my $sum = eval join '+', map { $_->{length} } @data; | |
706 is($sum, 81, 'iws - updated connection window'); | |
707 | |
708 # SETTINGS (initial window size, client side) | |
709 | |
710 # 6.9.2. Initial Flow-Control Window Size | |
711 # Both endpoints can adjust the initial window size for new streams by | |
712 # including a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS | |
713 # frame that forms part of the connection preface. The connection | |
714 # flow-control window can only be changed using WINDOW_UPDATE frames. | |
715 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
716 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
717 $s->h2_settings(0, 0x4 => 2**17); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
718 $s->h2_window(2**17); |
646 | 719 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
720 $sid = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
721 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 722 |
723 @data = grep { $_->{type} eq "DATA" } @$frames; | |
724 $sum = eval join '+', map { $_->{length} } @data; | |
725 is($sum, 2**16 + 80, 'iws - increased'); | |
726 | |
1272
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
727 # INITIAL_WINDOW_SIZE duplicate settings |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
728 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
729 # 6.5. SETTINGS |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
730 # Each parameter in a SETTINGS frame replaces any existing value for |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
731 # that parameter. Parameters are processed in the order in which they |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
732 # appear, and a receiver of a SETTINGS frame does not need to maintain |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
733 # any state other than the current value of its parameters. Therefore, |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
734 # the value of a SETTINGS parameter is the last value that is seen by a |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
735 # receiver. |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
736 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
737 $s = Test::Nginx::HTTP2->new(); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
738 $s->h2_window(2**17); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
739 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
740 $sid = $s->new_stream({ path => '/t1.html' }); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
741 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
742 $frames = $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
743 @data = grep { $_->{type} eq "DATA" } @$frames; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
744 $sum = eval join '+', map { $_->{length} } @data; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
745 is($sum, 2**16 - 1, 'iws duplicate - default stream window'); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
746 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
747 # this should effect in extra stream window octect |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
748 # $s->h2_settings(0, 0x4 => 42, 0x4 => 2**16); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
749 { |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
750 local $SIG{PIPE} = 'IGNORE'; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
751 syswrite($s->{socket}, pack("x2C2x5nNnN", 12, 0x4, 4, 42, 4, 2**16)); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
752 } |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
753 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
754 $frames = $s->read(all => [{ sid => $sid, length => 1 }]); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
755 @data = grep { $_->{type} eq "DATA" } @$frames; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
756 $sum = eval join '+', map { $_->{length} } @data; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
757 is($sum, 1, 'iws duplicate - updated stream window'); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
758 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
759 # yet more octets to finish receiving the response |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
760 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
761 $s->h2_settings(0, 0x4 => 2**16 + 80); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
762 |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
763 $frames = $s->read(all => [{ sid => $sid, length => 80 }]); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
764 @data = grep { $_->{type} eq "DATA" } @$frames; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
765 $sum = eval join '+', map { $_->{length} } @data; |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
766 is($sum, 80, 'iws duplicate - updated stream window 2'); |
01010d9021b8
Tests: HTTP/2 INITIAL_WINDOW_SIZE duplicate settings handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
767 |
646 | 768 # probe for negative available space in a flow control window |
769 | |
770 # 6.9.2. Initial Flow-Control Window Size | |
771 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available | |
772 # space in a flow-control window to become negative. A sender MUST | |
773 # track the negative flow-control window and MUST NOT send new flow- | |
774 # controlled frames until it receives WINDOW_UPDATE frames that cause | |
775 # the flow-control window to become positive. | |
776 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
777 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
778 $sid = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
779 $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
646 | 780 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
781 $s->h2_window(1); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
782 $s->h2_settings(0, 0x4 => 42); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
783 $s->h2_window(1024, $sid); |
646 | 784 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
785 $frames = $s->read(all => [{ type => 'SETTINGS' }]); |
646 | 786 |
787 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; | |
788 ok($frame, 'negative window - SETTINGS frame ack'); | |
789 is($frame->{flags}, 1, 'negative window - SETTINGS flags ack'); | |
790 | |
791 ($frame) = grep { $_->{type} ne 'SETTINGS' } @$frames; | |
792 is($frame, undef, 'negative window - no data'); | |
793 | |
794 # predefined window size, minus new iws settings, minus window update | |
795 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
796 $s->h2_window(2**16 - 1 - 42 - 1024, $sid); |
646 | 797 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
798 $frames = $s->read(wait => 0.2); |
646 | 799 is(@$frames, 0, 'zero window - no data'); |
800 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
801 $s->h2_window(1, $sid); |
646 | 802 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
803 $frames = $s->read(all => [{ sid => $sid, length => 1 }]); |
646 | 804 is(@$frames, 1, 'positive window'); |
712
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
805 |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
806 SKIP: { |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
807 skip 'failed connection', 2 unless @$frames; |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
808 |
646 | 809 is(@$frames[0]->{type}, 'DATA', 'positive window - data'); |
810 is(@$frames[0]->{length}, 1, 'positive window - data length'); | |
811 | |
712
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
812 } |
649af6069976
Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
707
diff
changeset
|
813 |
1184
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
814 $s = Test::Nginx::HTTP2->new(); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
815 $s->h2_window(2**30); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
816 $s->h2_settings(0, 0x4 => 2**30); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
817 |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
818 $sid = $s->new_stream({ path => '/frame_size/tbig.html' }); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
819 |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
820 sleep 1; |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
821 $s->h2_settings(0, 0x5 => 2**15); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
822 |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
823 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
824 $lengths = join ' ', map { $_->{length} } @$frames; |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
825 unlike($lengths, qr/16384 0 16384/, 'SETTINGS ack after queued DATA'); |
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
826 |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
827 # ask write handler in sending large response |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
828 |
1107
d42cc683970d
Tests: skip unsafe HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1092
diff
changeset
|
829 SKIP: { |
d42cc683970d
Tests: skip unsafe HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1092
diff
changeset
|
830 skip 'unsafe socket tests', 4 unless $ENV{TEST_NGINX_UNSAFE}; |
d42cc683970d
Tests: skip unsafe HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1092
diff
changeset
|
831 |
1465
93633a10e33d
Tests: run HTTP/2 unsafe socket tests on a fresh connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
832 $s = Test::Nginx::HTTP2->new(); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
833 $sid = $s->new_stream({ path => '/tbig.html' }); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
834 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
835 $s->h2_window(2**30, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
836 $s->h2_window(2**30); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
837 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
838 sleep 1; |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
839 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
840 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
841 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
842 is($frame->{headers}->{':status'}, 200, 'large response - HEADERS'); |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
843 |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
844 @data = grep { $_->{type} eq "DATA" } @$frames; |
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
845 $sum = eval join '+', map { $_->{length} } @data; |
723
bc4d6e2bd031
Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
722
diff
changeset
|
846 is($sum, 5000000, 'large response - DATA'); |
704
626bc3a0fdaa
Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
702
diff
changeset
|
847 |
794
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
848 # Make sure http2 write handler doesn't break a connection. |
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
849 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
850 $sid = $s->new_stream(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
851 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
794
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
852 |
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
853 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
854 is($frame->{headers}->{':status'}, 200, 'new stream after large response'); |
fed83003c45c
Tests: one more HTTP/2 write handler test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
789
diff
changeset
|
855 |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
856 # write event send timeout |
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
857 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
858 $s = Test::Nginx::HTTP2->new(port(8086)); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
859 $sid = $s->new_stream({ path => '/tbig.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
860 $s->h2_window(2**30, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
861 $s->h2_window(2**30); |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
862 |
990
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
863 select undef, undef, undef, 2.1; |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
864 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
865 $s->h2_ping('SEE-THIS'); |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
866 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
867 $frames = $s->read(all => [{ type => 'PING' }]); |
763
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
868 ok(!grep ({ $_->{type} eq "PING" } @$frames), 'large response - send timeout'); |
2ba4058848d6
Tests: HTTP/2 test for write event timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
762
diff
changeset
|
869 |
1107
d42cc683970d
Tests: skip unsafe HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1092
diff
changeset
|
870 } |
d42cc683970d
Tests: skip unsafe HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1092
diff
changeset
|
871 |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
872 # SETTINGS_MAX_FRAME_SIZE |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
873 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
874 $s = Test::Nginx::HTTP2->new(); |
1184
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
875 $sid = $s->new_stream({ path => '/frame_size/t1.html' }); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
876 $s->h2_window(2**18, 1); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
877 $s->h2_window(2**18); |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
878 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
879 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
880 @data = grep { $_->{type} eq "DATA" } @$frames; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
881 is($data[0]->{length}, 2**14, 'max frame size - default'); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
882 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
883 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
884 $s->h2_settings(0, 0x5 => 2**15); |
1184
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
885 $sid = $s->new_stream({ path => '/frame_size/t1.html' }); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
886 $s->h2_window(2**18, 1); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
887 $s->h2_window(2**18); |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
888 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
889 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
680
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
890 @data = grep { $_->{type} eq "DATA" } @$frames; |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
891 is($data[0]->{length}, 2**15, 'max frame size - custom'); |
85e368105c8b
Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents:
679
diff
changeset
|
892 |
1182
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
893 # SETTINGS_INITIAL_WINDOW_SIZE + SETTINGS_MAX_FRAME_SIZE |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
894 # Expanding available stream window should not result in emitting |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
895 # new frames before remaining SETTINGS parameters were applied. |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
896 |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
897 $s = Test::Nginx::HTTP2->new(); |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
898 $s->h2_window(2**17); |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
899 $s->h2_settings(0, 0x4 => 42); |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
900 |
1184
89b4bdd1346a
Tests: added HTTP/2 SETTINGS test for no ack until queued DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1183
diff
changeset
|
901 $sid = $s->new_stream({ path => '/frame_size/t1.html' }); |
1185
368ab1d8ed8b
Tests: unbreak h2.t with aio.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1184
diff
changeset
|
902 $s->read(all => [{ sid => $sid, length => 42 }]); |
1182
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
903 |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
904 $s->h2_settings(0, 0x4 => 2**17, 0x5 => 2**15); |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
905 |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
906 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
907 @data = grep { $_->{type} eq "DATA" } @$frames; |
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
908 $lengths = join ' ', map { $_->{length} } @data; |
1185
368ab1d8ed8b
Tests: unbreak h2.t with aio.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1184
diff
changeset
|
909 is($lengths, '32768 32768 38', 'multiple SETTINGS'); |
1182
83c88a830a45
Tests: added HTTP/2 SETTINGS test with multiple parameters.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1174
diff
changeset
|
910 |
646 | 911 # stream multiplexing + WINDOW_UPDATE |
912 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
913 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
914 $sid = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
915 $frames = $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
646 | 916 |
917 @data = grep { $_->{type} eq "DATA" } @$frames; | |
918 $sum = eval join '+', map { $_->{length} } @data; | |
919 is($sum, 2**16 - 1, 'multiple - stream1 data'); | |
920 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
921 my $sid2 = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
922 $frames = $s->read(all => [{ sid => $sid2, fin => 0x4 }]); |
646 | 923 |
924 @data = grep { $_->{type} eq "DATA" } @$frames; | |
925 is(@data, 0, 'multiple - stream2 no data'); | |
926 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
927 $s->h2_window(2**17, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
928 $s->h2_window(2**17, $sid2); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
929 $s->h2_window(2**17); |
646 | 930 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
931 $frames = $s->read(all => [ |
646 | 932 { sid => $sid, fin => 1 }, |
933 { sid => $sid2, fin => 1 } | |
934 ]); | |
935 | |
936 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames; | |
937 $sum = eval join '+', map { $_->{length} } @data; | |
938 is($sum, 81, 'multiple - stream1 remain data'); | |
939 | |
940 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames; | |
941 $sum = eval join '+', map { $_->{length} } @data; | |
942 is($sum, 2**16 + 80, 'multiple - stream2 full data'); | |
943 | |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
944 # http2_max_concurrent_streams |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
945 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
946 $s = Test::Nginx::HTTP2->new(port(8083), pure => 1); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
947 $frames = $s->read(all => [{ type => 'SETTINGS' }]); |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
948 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
949 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
950 is($frame->{3}, 1, 'http2_max_concurrent_streams SETTINGS'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
951 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
952 $s->h2_window(2**18); |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
953 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
954 $sid = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
955 $frames = $s->read(all => [{ sid => $sid, length => 2 ** 16 - 1 }]); |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
956 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
957 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
958 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
959 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
960 $sid2 = $s->new_stream({ path => '/t1.html' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
961 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
654
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
962 |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
963 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
964 isnt($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 2'); |
a64fe1054fb4
Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
653
diff
changeset
|
965 |
667
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
966 ($frame) = grep { $_->{type} eq "RST_STREAM" && $_->{sid} == $sid2 } @$frames; |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
967 is($frame->{sid}, $sid2, 'http2_max_concurrent_streams RST_STREAM sid'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
968 is($frame->{length}, 4, 'http2_max_concurrent_streams RST_STREAM length'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
969 is($frame->{flags}, 0, 'http2_max_concurrent_streams RST_STREAM flags'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
970 is($frame->{code}, 7, 'http2_max_concurrent_streams RST_STREAM code'); |
0247e314e991
Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
662
diff
changeset
|
971 |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
972 # properly skip header field that's not/never indexed from discarded streams |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
973 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
974 $sid2 = $s->new_stream({ headers => [ |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
975 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
976 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
977 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
978 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
979 { name => 'x-foo', value => 'Foo', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
980 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
981 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
982 # also if split across writes |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
983 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
984 $sid2 = $s->new_stream({ split => [ 22 ], headers => [ |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
985 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
986 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
987 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
988 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
989 { name => 'x-bar', value => 'Bar', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
990 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
991 |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
992 # also if split across frames |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
993 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
994 $sid2 = $s->new_stream({ continuation => [ 17 ], headers => [ |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
995 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
996 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
997 { name => ':path', value => '/', mode => 6 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
998 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
999 { name => 'x-baz', value => 'Baz', mode => 2 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1000 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1001 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1002 $s->h2_window(2**16, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1003 $s->read(all => [{ sid => $sid, fin => 1 }]); |
661
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
1004 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1005 $sid = $s->new_stream({ headers => [ |
715
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1006 { name => ':method', value => 'GET' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1007 { name => ':scheme', value => 'http' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1008 { name => ':path', value => '/t2.html' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1009 { name => ':authority', value => 'localhost' }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1010 # make sure that discarded streams updated dynamic table |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1011 { name => 'x-foo', value => 'Foo', mode => 0 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1012 { name => 'x-bar', value => 'Bar', mode => 0 }, |
9ee52e137f3d
Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
714
diff
changeset
|
1013 { name => 'x-baz', value => 'Baz', mode => 0 }]}); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1014 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
661
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
1015 |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
1016 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
1017 is($frame->{headers}->{':status'}, 200, 'http2_max_concurrent_streams 3'); |
c99c30afc1c9
Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
660
diff
changeset
|
1018 |
646 | 1019 |
1020 # some invalid cases below | |
1021 | |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
1022 # invalid connection preface |
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
1023 |
1898
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1024 TODO: { |
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1025 local $TODO = 'not yet' unless $t->has_version('1.25.1'); |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
1026 |
1898
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1027 like(http('x' x 16), qr/400 Bad Request/, 'invalid preface'); |
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1028 like(http('PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8), qr/400 Bad Request/, |
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1029 'invalid preface 2'); |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
1030 |
1898
26252394dd58
Tests: updated HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1710
diff
changeset
|
1031 } |
728
61800918f647
Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents:
727
diff
changeset
|
1032 |
646 | 1033 # GOAWAY on SYN_STREAM with even StreamID |
1034 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1035 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1036 $s->new_stream({ path => '/' }, 2); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1037 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
646 | 1038 |
1039 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
1040 ok($frame, 'even stream - GOAWAY frame'); | |
1041 is($frame->{code}, 1, 'even stream - error code'); | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1042 is($frame->{last_sid}, 0, 'even stream - last stream'); |
646 | 1043 |
1044 # GOAWAY on SYN_STREAM with backward StreamID | |
1045 | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1046 # 5.1.1. Stream Identifiers |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1047 # The first use of a new stream identifier implicitly closes all |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1048 # streams in the "idle" state <..> with a lower-valued stream identifier. |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1049 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1050 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1051 $sid = $s->new_stream({ path => '/' }, 3); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1052 $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 1053 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1054 $sid2 = $s->new_stream({ path => '/' }, 1); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1055 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
646 | 1056 |
1057 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
1058 ok($frame, 'backward stream - GOAWAY frame'); | |
1059 is($frame->{code}, 1, 'backward stream - error code'); | |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1060 is($frame->{last_sid}, $sid, 'backward stream - last stream'); |
646 | 1061 |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1062 # GOAWAY on the second SYN_STREAM with same StreamID |
646 | 1063 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1064 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1065 $sid = $s->new_stream({ path => '/' }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1066 $s->read(all => [{ sid => $sid, fin => 1 }]); |
646 | 1067 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1068 $sid2 = $s->new_stream({ path => '/' }, $sid); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1069 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1070 |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1071 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1072 ok($frame, 'dup stream - GOAWAY frame'); |
646 | 1073 is($frame->{code}, 1, 'dup stream - error code'); |
669
0c442e551ba1
Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
668
diff
changeset
|
1074 is($frame->{last_sid}, $sid, 'dup stream - last stream'); |
646 | 1075 |
754
84a52b6d6343
Tests: HTTP/2 regression test for incomplete HEADERS payload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
748
diff
changeset
|
1076 # aborted stream with zero HEADERS payload followed by client connection close |
84a52b6d6343
Tests: HTTP/2 regression test for incomplete HEADERS payload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
748
diff
changeset
|
1077 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1078 Test::Nginx::HTTP2->new()->new_stream({ split => [ 9 ], abort => 1 }); |
754
84a52b6d6343
Tests: HTTP/2 regression test for incomplete HEADERS payload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
748
diff
changeset
|
1079 |
697
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1080 # unknown frame type |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1081 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1082 $s = Test::Nginx::HTTP2->new(); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1083 $s->h2_unknown('payload'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1084 $s->h2_ping('SEE-THIS'); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1085 $frames = $s->read(all => [{ type => 'PING' }]); |
697
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1086 |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1087 ($frame) = grep { $_->{type} eq "PING" } @$frames; |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1088 is($frame->{value}, 'SEE-THIS', 'unknown frame type'); |
46f698a7e59c
Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents:
696
diff
changeset
|
1089 |
755
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1090 # graceful shutdown with stream waiting on HEADERS payload |
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1091 |
1650
cdba06625d65
Tests: simplified testing configuration in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1649
diff
changeset
|
1092 my $grace = Test::Nginx::HTTP2->new(port(8087)); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1093 $grace->new_stream({ split => [ 9 ], abort => 1 }); |
755
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1094 |
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1095 # graceful shutdown waiting on incomplete request body DATA frames |
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1096 |
1650
cdba06625d65
Tests: simplified testing configuration in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1649
diff
changeset
|
1097 my $grace3 = Test::Nginx::HTTP2->new(port(8087)); |
cdba06625d65
Tests: simplified testing configuration in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1649
diff
changeset
|
1098 $sid = $grace3->new_stream({ path => '/proxy/t2.html', body_more => 1 }); |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1099 $grace3->h2_body('TEST', { body_more => 1 }); |
755
f95aa716624e
Tests: HTTP/2 tests for alerts on graceful shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
754
diff
changeset
|
1100 |
1065
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1101 # GOAWAY without awaiting active streams, further streams ignored |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1102 |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1103 $s = Test::Nginx::HTTP2->new(port(8080)); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1104 $sid = $s->new_stream({ path => '/t1.html' }); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1105 $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1106 |
1206
c99c1f43cb15
Tests: reload() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1185
diff
changeset
|
1107 $t->reload(); |
1065
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1108 |
1066
23418577df58
Tests: tweak HTTP/2 GOAWAY test with no new stream after reload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1065
diff
changeset
|
1109 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
23418577df58
Tests: tweak HTTP/2 GOAWAY test with no new stream after reload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1065
diff
changeset
|
1110 |
23418577df58
Tests: tweak HTTP/2 GOAWAY test with no new stream after reload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1065
diff
changeset
|
1111 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
23418577df58
Tests: tweak HTTP/2 GOAWAY test with no new stream after reload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1065
diff
changeset
|
1112 is($frame->{last_sid}, $sid, 'GOAWAY with active stream - last sid'); |
23418577df58
Tests: tweak HTTP/2 GOAWAY test with no new stream after reload.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1065
diff
changeset
|
1113 |
1065
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1114 $sid2 = $s->new_stream(); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1115 $frames = $s->read(all => [{ sid => $sid2, fin => 0x4 }], wait => 0.5); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1116 |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1117 ($frame) = grep { $_->{type} eq 'HEADERS' } @$frames; |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1118 is($frame, undef, 'GOAWAY with active stream - no new stream'); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1119 |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1120 $s->h2_window(100, $sid); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1121 $s->h2_window(100); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1122 $frames = $s->read(all => [{ sid => $sid, fin => 0x1 }]); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1123 |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1124 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames; |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1125 $sum = eval join '+', map { $_->{length} } @data; |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1126 is($sum, 81, 'GOAWAY with active stream - active stream DATA after GOAWAY'); |
2d4343a47c6d
Tests: more HTTP/2 GOAWAY tests with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
1127 |
990
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1128 # GOAWAY - force closing a connection by server with idle or active streams |
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1129 |
1651
a78eedc39484
Tests: h2.t tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1650
diff
changeset
|
1130 $s = Test::Nginx::HTTP2->new(port(8086)); |
990
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1131 $sid = $s->new_stream(); |
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1132 $s->read(all => [{ sid => $sid, fin => 1 }]); |
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1133 |
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1134 my $active = Test::Nginx::HTTP2->new(port(8086)); |
995
35739834ecd9
Tests: fixed HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
990
diff
changeset
|
1135 $sid = $active->new_stream({ path => '/t1.html' }); |
35739834ecd9
Tests: fixed HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
990
diff
changeset
|
1136 $active->read(all => [{ sid => $sid, length => 2**16 - 1 }]); |
990
eb49d29d5447
Tests: redo 892737e9fd31 without flaky send_timeout adjustments.
Sergey Kandaurov <pluknet@nginx.com>
parents:
984
diff
changeset
|
1137 |
646 | 1138 $t->stop(); |
1139 | |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
1140 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
646 | 1141 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
984
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1142 ok($frame, 'GOAWAY on connection close - idle stream'); |
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1143 |
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1144 $frames = $active->read(all => [{ type => 'GOAWAY' }]); |
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1145 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1146 ok($frame, 'GOAWAY on connection close - active stream'); |
892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
1147 |
646 | 1148 ############################################################################### |
1149 | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
1150 sub gunzip_like { |
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
1151 my ($in, $re, $name) = @_; |
646 | 1152 |
1153 SKIP: { | |
1154 eval { require IO::Uncompress::Gunzip; }; | |
1155 Test::More::skip( | |
1156 "IO::Uncompress::Gunzip not installed", 1) if $@; | |
1157 | |
1158 my $out; | |
1159 | |
1160 IO::Uncompress::Gunzip::gunzip(\$in => \$out); | |
1161 | |
647
4e36550410b3
Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
646
diff
changeset
|
1162 like($out, $re, $name); |
646 | 1163 } |
1164 } | |
1165 | |
1166 ############################################################################### |