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