annotate h2.t @ 1710:f3de5730bc06

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