annotate h2.t @ 679:b60c1a207675

Tests: fixed HTTP/2 tests with large frames. Compensate for an already read frame header.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 08 Sep 2015 14:58:56 +0300
parents 5d258aa5ebc5
children 85e368105c8b
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 IO::Select;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 use Socket qw/ CRLF /;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 BEGIN { use FindBin; chdir($FindBin::Bin); }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 use lib 'lib';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 use Test::Nginx;
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
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
28 eval { require IO::Socket::SSL; };
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
29 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
32
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/)
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
34 ->has(qw/limit_conn rewrite realip shmem/)
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
35 ->has_daemon('openssl')->plan(168);
646
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 $t->write_file_expand('nginx.conf', <<'EOF');
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 %%TEST_GLOBALS%%
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 daemon off;
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 events {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 http {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 %%TEST_GLOBALS_HTTP%%
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 limit_conn_zone $binary_remote_addr zone=conn:1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 output_buffers 2 16k;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 listen 127.0.0.1:8080 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 listen 127.0.0.1:8081;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 listen 127.0.0.1:8082 proxy_protocol http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 listen 127.0.0.1:8084 http2 ssl;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 server_name localhost;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 ssl_certificate_key localhost.key;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 ssl_certificate localhost.crt;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 location / {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 add_header X-Header X-Foo;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 add_header X-Sent-Foo $http_x_foo;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 add_header X-Referer $http_referer;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 return 200 'body';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 location /t {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 location /t3.html {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 limit_conn conn 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 location /gzip.html {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 gzip on;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 gzip_min_length 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 alias %%TESTDIR%%/t2.html;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 location /pp {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 set_real_ip_from 127.0.0.1/32;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 real_ip_header proxy_protocol;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 alias %%TESTDIR%%/t2.html;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 add_header X-PP $remote_addr;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 }
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
85 location /h2 {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
86 return 200 $http2;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
87 }
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
88 location /chunk_size {
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
89 http2_chunk_size 1;
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
90 return 200 'body';
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
91 }
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 location /redirect {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 error_page 405 /;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 return 405;
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 location /return301 {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 return 301;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 location /return301_absolute {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 return 301 text;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 location /return301_relative {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 return 301 /;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 location /proxy/ {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106 add_header X-UC-a $upstream_cookie_a;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 add_header X-UC-c $upstream_cookie_c;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 proxy_pass http://127.0.0.1:8083/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 proxy_cache_valid 1m;
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
111 proxy_set_header X-Cookie-a $cookie_a;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
112 proxy_set_header X-Cookie-c $cookie_c;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 location /proxy2/ {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 add_header X-Body "$request_body";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 proxy_pass http://127.0.0.1:8081/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118 proxy_cache_valid 1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 location /proxy_buffering_off {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 proxy_pass http://127.0.0.1:8081/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 proxy_cache_valid 1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 proxy_buffering off;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 location /set-cookie {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 add_header Set-Cookie a=b;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 add_header Set-Cookie c=d;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 return 200;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 location /cookie {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 add_header X-Cookie $http_cookie;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 add_header X-Cookie-a $cookie_a;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 add_header X-Cookie-c $cookie_c;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 return 200;
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 }
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 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 listen 127.0.0.1:8085 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 server_name localhost;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 return 200 first;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 listen 127.0.0.1:8085 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 server_name localhost2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 return 200 second;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 }
654
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
150
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
151 server {
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
152 listen 127.0.0.1:8086 http2;
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
153 server_name localhost;
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
154
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
155 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
156 }
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 $t->write_file('openssl.conf', <<EOF);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 [ req ]
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 default_bits = 2048
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 encrypt_key = no
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165 distinguished_name = req_distinguished_name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 [ req_distinguished_name ]
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 my $d = $t->testdir();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171 foreach my $name ('localhost') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 system('openssl req -x509 -new '
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 . "-config '$d/openssl.conf' -subj '/CN=$name/' "
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 . "-out '$d/$name.crt' -keyout '$d/$name.key' "
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 . ">>$d/openssl.out 2>&1") == 0
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 or die "Can't create certificate for $name: $!\n";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
179 $t->run_daemon(\&http_daemon);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
180 $t->run()->waitforsocket('127.0.0.1:8083');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
181
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
182 # 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
183
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
184 $t->write_file('t1.html',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
185 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
186 $t->write_file('tbig.html',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
187 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
188
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 $t->write_file('t2.html', 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
190 $t->write_file('t3.html', 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
191
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192 my %cframe = (
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
193 0 => { name => 'DATA', value => \&data },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
194 1 => { name => 'HEADERS', value => \&headers },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195 # 2 => { name => 'PRIORITY', value => \&priority },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
196 3 => { name => 'RST_STREAM', value => \&rst_stream },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
197 4 => { name => 'SETTINGS', value => \&settings },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
198 # 5 => { name => 'PUSH_PROIMSE', value => \&push_promise },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
199 6 => { name => 'PING', value => \&ping },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
200 7 => { name => 'GOAWAY', value => \&goaway },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
201 8 => { name => 'WINDOW_UPDATE', value => \&window_update },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
202 # 9 => { name => 'CONTINUATION', value => \&continuation },
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
205 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
206
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
207 # SETTINGS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
208
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
209 my $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
210 my $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
211 { type => 'WINDOW_UPDATE' },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
212 { type => 'SETTINGS'}
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
213 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215 my ($frame) = grep { $_->{type} eq 'WINDOW_UPDATE' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216 ok($frame, 'WINDOW_UPDATE frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217 is($frame->{flags}, 0, 'WINDOW_UPDATE zero flags');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
218 is($frame->{sid}, 0, 'WINDOW_UPDATE zero sid');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
219 is($frame->{length}, 4, 'WINDOW_UPDATE fixed length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
221 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
222 ok($frame, 'SETTINGS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
223 is($frame->{flags}, 0, 'SETTINGS flags');
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
224 is($frame->{sid}, 0, 'SETTINGS stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
225
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
226 h2_settings($sess, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
227 h2_settings($sess, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
228
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
229 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
230
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
231 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
232 ok($frame, 'SETTINGS frame ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
233 is($frame->{flags}, 1, 'SETTINGS flags ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
234
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
235 # PING
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
236
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
237 h2_ping($sess, 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
238 $frames = h2_read($sess, all => [{ type => 'PING' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
239
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
240 ($frame) = grep { $_->{type} eq "PING" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
241 ok($frame, 'PING frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
242 is($frame->{value}, 'SEE-THIS', 'PING payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
243 is($frame->{flags}, 1, 'PING flags ack');
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
244 is($frame->{sid}, 0, 'PING stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
245
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
246 # GET
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
247
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
248 my $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
249 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
250
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
251 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
252 ok($frame, 'HEADERS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
253 is($frame->{sid}, $sid, 'HEADERS stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
254 is($frame->{headers}->{':status'}, 200, 'HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
255 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
256
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
257 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
258 ok($frame, 'DATA frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
259 is($frame->{length}, length 'body', 'DATA length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
260 is($frame->{data}, 'body', 'DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
261
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
262 # GET in the new stream on same connection
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
263
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
264 $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
265 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
266
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
267 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
268 is($frame->{sid}, $sid, 'HEADERS stream 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
269 is($frame->{headers}->{':status'}, 200, 'HEADERS status 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
270 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
271
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
272 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
273 ok($frame, 'DATA frame 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
274 is($frame->{sid}, $sid, 'HEADERS stream 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
275 is($frame->{length}, length 'body', 'DATA length 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
276 is($frame->{data}, 'body', 'DATA payload 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
277
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
278 # various HEADERS compression/encoding, see hpack() for mode details
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
279
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
280 # 6.1. Indexed Header Field Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
281
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
282 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
283 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
284 { 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
285 { 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
286 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
287 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
288
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
289 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
290 is($frame->{headers}->{':status'}, 200, 'indexed header field');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
291
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
292 # 6.2.1. Literal Header Field with Incremental Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
293
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
294 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
295 { name => ':method', value => 'GET', mode => 1, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
296 { name => ':scheme', value => 'http', mode => 1, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
297 { name => ':path', value => '/', mode => 1, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
298 { name => ':authority', value => 'localhost', mode => 1, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
299 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
300
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
301 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
302 is($frame->{headers}->{':status'}, 200, 'literal with indexing');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
303
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
304 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
305 { name => ':method', value => 'GET', mode => 1, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 { name => ':scheme', value => 'http', mode => 1, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
307 { name => ':path', value => '/', mode => 1, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
308 { name => ':authority', value => 'localhost', mode => 1, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312 is($frame->{headers}->{':status'}, 200, 'literal with indexing - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
313
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
314 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
316 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
317 { name => ':method', value => 'GET', mode => 2, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
318 { name => ':scheme', value => 'http', mode => 2, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
319 { name => ':path', value => '/', mode => 2, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
320 { name => ':authority', value => 'localhost', mode => 2, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
321 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
322
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
323 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
324 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
325
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
326 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
327 { name => ':method', value => 'GET', mode => 2, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
328 { name => ':scheme', value => 'http', mode => 2, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
329 { name => ':path', value => '/', mode => 2, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
330 { name => ':authority', value => 'localhost', mode => 2, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
331 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
333 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
334 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
335
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
336 # 6.2.2. Literal Header Field without Indexing
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 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
339 { name => ':method', value => 'GET', mode => 3, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
340 { name => ':scheme', value => 'http', mode => 3, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
341 { name => ':path', value => '/', mode => 3, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
342 { name => ':authority', value => 'localhost', mode => 3, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
343 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
344
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
345 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
346 is($frame->{headers}->{':status'}, 200, 'literal without indexing');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
347
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
348 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
349 { name => ':method', value => 'GET', mode => 3, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
350 { name => ':scheme', value => 'http', mode => 3, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
351 { name => ':path', value => '/', mode => 3, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
352 { name => ':authority', value => 'localhost', mode => 3, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
353 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
354
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
355 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
356 is($frame->{headers}->{':status'}, 200, 'literal without indexing - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
357
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
358 # 6.2.2. Literal Header Field without Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
359
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
360 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
361 { name => ':method', value => 'GET', mode => 4, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
362 { name => ':scheme', value => 'http', mode => 4, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
363 { name => ':path', value => '/', mode => 4, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
364 { name => ':authority', value => 'localhost', mode => 4, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
365 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
368 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new');
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 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
371 { name => ':method', value => 'GET', mode => 4, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
372 { name => ':scheme', value => 'http', mode => 4, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
373 { name => ':path', value => '/', mode => 4, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
374 { name => ':authority', value => 'localhost', mode => 4, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
375 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
376
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
377 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
378 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
379
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
380 # 6.2.3. Literal Header Field Never Indexed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
381
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
382 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
383 { name => ':method', value => 'GET', mode => 5, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
384 { name => ':scheme', value => 'http', mode => 5, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
385 { name => ':path', value => '/', mode => 5, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
386 { name => ':authority', value => 'localhost', mode => 5, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
387 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
388
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
389 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
390 is($frame->{headers}->{':status'}, 200, 'literal never indexed');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
391
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
392 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
393 { name => ':method', value => 'GET', mode => 5, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
394 { name => ':scheme', value => 'http', mode => 5, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
395 { name => ':path', value => '/', mode => 5, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
396 { name => ':authority', value => 'localhost', mode => 5, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
397 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
398
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
399 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
400 is($frame->{headers}->{':status'}, 200, 'literal never indexed - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
401
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
402 # 6.2.2. Literal Header Field Never Indexed -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
403
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
404 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
405 { name => ':method', value => 'GET', mode => 6, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
406 { name => ':scheme', value => 'http', mode => 6, huff => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
407 { name => ':path', value => '/', mode => 6, huff => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
408 { name => ':authority', value => 'localhost', mode => 6, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
409 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
410
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
411 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
412 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
413
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
414 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
415 { name => ':method', value => 'GET', mode => 6, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
416 { name => ':scheme', value => 'http', mode => 6, huff => 1 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
417 { name => ':path', value => '/', mode => 6, huff => 1 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
418 { name => ':authority', value => 'localhost', mode => 6, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
419 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
420
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
421 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
422 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
423
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
424 # reuse literal with indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
425
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
426 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
427 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
428 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
429 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
430 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
431 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
432 { name => 'referer', value => 'foo', mode => 1 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
433 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
434
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
435 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
436 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
437
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
438 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
439 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
440 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
441 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
442 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
443 { name => 'referer', value => 'foo', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
444 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
445
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
446 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
447 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - indexed');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
448
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
449 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
450 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
451 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
452 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
453 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
454 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
455 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
458 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'name with indexing - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
459
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
460 # reuse literal with indexing - reused name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
461
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
462 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
463 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
464 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
465 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
466 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
467 { name => 'x-foo', value => 'X-Bar', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
468 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
469
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
470 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
471 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'name with indexing - indexed');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
472
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
473 # 6.3. Dynamic Table Size Update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
474
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
475 # remove some indexed headers from the dynamic table
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
476 # by maintaining dynamic table space only for index 0
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
477 # 'x-foo' has index 0, and 'referer' has index 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
478
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
479 $sid = new_stream($sess, { table_size => 61, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
480 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
481 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
482 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
483 { name => 'x-foo', value => 'X-Bar', mode => 0 },
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
484 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
485 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
486
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
487 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
488 isnt($frame, undef, 'updated table size - remaining index');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
489
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
490 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
491 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
492 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
493 { name => ':path', value => '/', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
494 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
495 { name => 'referer', value => 'foo', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
496 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
497
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
498 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
499 is($frame, undef, 'invalid index');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
500
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
501 # 5.4.1. Connection Error Handling
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
502 # An endpoint that encounters a connection error SHOULD first send a
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
503 # GOAWAY frame <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
504
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
505 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
506 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
507
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
508 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
509 ok($frame, 'invalid index - GOAWAY');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
510
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
511 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
512
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
513 h2_ping($sess, 'SEE-THIS');
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
514 is(@{h2_read($sess, all => [{ type => 'PING' }])}, 0, 'invalid index - PING');
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
515 is($sess->{socket}->connected, undef, 'invalid index - connection close');
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
516
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
517 # HEAD
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
518
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
519 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
520 $sid = new_stream($sess, { method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
521 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
522
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
523 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
524 is($frame->{sid}, $sid, 'HEAD - HEADERS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
525 is($frame->{headers}->{':status'}, 200, 'HEAD - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
526 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEAD - HEADERS header');
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, undef, 'HEAD - no body');
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 # GET with PROXY protocol
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
532
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
533 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
534 $sess = new_session(8082, proxy => $proxy);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
535 $sid = new_stream($sess, { path => '/pp' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
536 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
537
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
538 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
539 ok($frame, 'PROXY HEADERS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
540 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
541
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
542 # range filter
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
545 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
546 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
547 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
548 { 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
549 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
550 { name => 'range', value => 'bytes=10-19', mode => 1 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
551 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
552
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
553 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
554 is($frame->{headers}->{':status'}, 206, 'range - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
555
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
556 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
557 is($frame->{length}, 10, 'range - DATA length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
558 is($frame->{data}, '002XXXX000', 'range - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
559
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
560 # $http2
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
561
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
562 $sess = new_session();
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
563 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
564 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
565
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
566 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
567 is($frame->{data}, 'h2c', 'http variable - h2c');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
568
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
569 # SSL/TLS connection, NPN
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
570
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
571 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
572 eval { IO::Socket::SSL->can_npn() or die; };
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
573 skip 'OpenSSL NPN support required', 1 if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
574
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
575 $sess = new_session(8084, SSL => 1, npn => 'h2');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
576 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
577 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
578
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
579 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
580 is($frame->{data}, 'h2', 'http variable - npn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
581
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
582 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
583
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
584 # SSL/TLS connection, ALPN
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
585
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
586 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
587 eval { IO::Socket::SSL->can_alpn() or die; };
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
588 skip 'OpenSSL ALPN support required', 1 if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
589
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
590 $sess = new_session(8084, SSL => 1, alpn => 'h2');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
591 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
592 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
593
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
594 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
595 is($frame->{data}, 'h2', 'http variable - alpn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
596
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
597 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
598
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
599 # http2_chunk_size=1
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
600
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
601 $sess = new_session();
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
602 $sid = new_stream($sess, { path => '/chunk_size' });
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
603 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
604
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
605 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
606 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
607 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
608 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
609
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
610 # CONTINUATION
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
611
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
612 $sess = new_session();
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
613 $sid = new_stream($sess, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
614 { name => ':method', value => 'HEAD', mode => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
615 { 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
616 { 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
617 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
618 h2_continue($sess, $sid, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
619 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
620 h2_continue($sess, $sid, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
621 { name => 'referer', value => 'foo', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
622 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
623
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
624 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
625 is($frame, undef, 'CONTINUATION - fragment 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
626
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
627 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
628 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
629 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
630
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
631 # frame padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
632
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
633 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
634 $sid = new_stream($sess, { padding => 42, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
635 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
636 { 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
637 { 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
638 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
639 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
640
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
641 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
642 is($frame->{headers}->{':status'}, 200, 'padding - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
643
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
644 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
645 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
646 { 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
647 { 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
648 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
649 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
650
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
651 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
652 is($frame->{headers}->{':status'}, 200, 'padding - next stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
653
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
654 # request header field with multiple values
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
655
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
656 # 8.1.2.5. Compressing the Cookie Header Field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
657 # To allow for better compression efficiency, the Cookie header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
658 # MAY be split into separate header fields <..>.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
659
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
660 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
661 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
662 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
663 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
664 { name => ':path', value => '/cookie', mode => 2 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
665 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
666 { name => 'cookie', value => 'a=b', mode => 2},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
667 { name => 'cookie', value => 'c=d', mode => 2}]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
668 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
669
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
670 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
671 is($frame->{headers}->{'x-cookie-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
672 'multiple request header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
673 is($frame->{headers}->{'x-cookie-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
674 'multiple request header fields - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
675 is($frame->{headers}->{'x-cookie'}, 'a=b; c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
676 'multiple request header fields - semi-colon');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
677
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
678 # request header field with multiple values to HTTP backend
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 # 8.1.2.5. Compressing the Cookie Header Field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
681 # these MUST be concatenated into a single octet string
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
682 # using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
683 # before being passed into a non-HTTP/2 context, such as an HTTP/1.1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
684 # connection <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
685
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
686 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
687 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
688 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
689 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
690 { name => ':path', value => '/proxy/cookie', mode => 2 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
691 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
692 { name => 'cookie', value => 'a=b', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
693 { name => 'cookie', value => 'c=d', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
694 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
695
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
696 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
697 is($frame->{headers}->{'x-sent-cookie'}, 'a=b; c=d',
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
698 'multiple request header fields proxied - semi-colon');
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
699 is($frame->{headers}->{'x-sent-cookie2'}, '',
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
700 'multiple request header fields proxied - dublicate cookie');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
701 is($frame->{headers}->{'x-sent-cookie-a'}, 'b',
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
702 'multiple request header fields proxied - cookie 1');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
703 is($frame->{headers}->{'x-sent-cookie-c'}, 'd',
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
704 'multiple request header fields proxied - cookie 2');
646
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 # response header field with multiple values
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
707
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
708 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
709 $sid = new_stream($sess, { path => '/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
710 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
711
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
712 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
713 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
714 'multiple response header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
715 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
716 'multiple response header fields - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
717
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
718 # response header field with multiple values from HTTP backend
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
719
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
720 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
721 $sid = new_stream($sess, { path => '/proxy/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
722 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
723
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
724 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
725 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
726 'multiple response header proxied - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
727 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
728 'multiple response header proxied - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
729 is($frame->{headers}->{'x-uc-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
730 'multiple response header proxied - upstream cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
731 is($frame->{headers}->{'x-uc-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
732 'multiple response header proxied - upstream cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
733
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
734 # internal redirect
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
735
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
736 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
737 $sid = new_stream($sess, { path => '/redirect' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
738 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
739
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
740 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
741 is($frame->{headers}->{':status'}, 405, 'redirect - HEADERS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
742
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
743 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
744 ok($frame, 'redirect - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
745 is($frame->{data}, 'body', 'redirect - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
746
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
747 # return 301 with absolute URI
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
748
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
749 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
750 $sid = new_stream($sess, { path => '/return301_absolute' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
751 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
752
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
753 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
754 is($frame->{headers}->{':status'}, 301, 'return 301 absolute - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
755 is($frame->{headers}->{'location'}, 'text', 'return 301 absolute - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
756
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
757 # return 301 with relative URI
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
758
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
759 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
760 $sid = new_stream($sess, { path => '/return301_relative' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
761 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
762
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
763 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
764 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
765 is($frame->{headers}->{'location'}, 'http://127.0.0.1:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
766 'return 301 relative - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
767
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
768 # return 301 with relative URI and ':authority' request header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
769
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
770 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
771 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
772 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
773 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
774 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
775 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
776 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
777
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
778 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
779 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
780 'return 301 relative - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
781 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
782 'return 301 relative - authority - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
783
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
784 # return 301 with relative URI and 'host' request header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
785
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
786 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
787 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
788 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
789 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
790 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
791 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
792 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
793
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
794 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
795 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
796 'return 301 relative - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
797 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
798 'return 301 relative - host - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
799
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
800 # virtual host
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
801
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
802 $sess = new_session(8085);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
803 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
804 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
805 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
806 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
807 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
808 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
809
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
810 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
811 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
812 'virtual host - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
813
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
814 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
815 is($frame->{data}, 'first', 'virtual host - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
816
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
817 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
818 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
819 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
820 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
821 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
822 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
823
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
824 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
825 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
826 'virtual host - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
827
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
828 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
829 is($frame->{data}, 'first', 'virtual host - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
830
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
831 # virtual host - second
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
832
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
833 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
834 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
835 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
836 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
837 { name => 'host', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
838 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
839
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
840 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
841 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
842 'virtual host 2 - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
843
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
844 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
845 is($frame->{data}, 'second', 'virtual host 2 - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
846
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
847 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
848 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
849 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
850 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
851 { name => ':authority', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
852 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
853
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
854 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
855 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
856 'virtual host 2 - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
857
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
858 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
859 is($frame->{data}, 'second', 'virtual host 2 - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
860
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
861 # gzip tests for internal nginx version
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
862
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
863 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
864 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
865 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
866 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
867 { 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
868 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
869 { name => 'accept-encoding', value => 'gzip' }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
870 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
871
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
872 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
873 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
874
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
875 ($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
876 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
877
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
878 # simple proxy cache test
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
879
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
880 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
881 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
882 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
883
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
884 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
885 is($frame->{headers}->{':status'}, '200', 'proxy cache');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
886
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
887 my $etag = $frame->{headers}->{'etag'};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
888
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
889 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
890 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
891 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
892
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
893 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
894 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
895 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
896 { name => ':path', value => '/proxy2/t2.html?2' },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
897 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
898 { name => 'if-none-match', value => $etag }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
899 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
900
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
901 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
902 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
903
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
904 # HEADERS could be received with fin, followed by DATA
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
905
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
906 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
907 $sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
908
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
909 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
910 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
911 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
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 # HEAD on empty cache with proxy_buffering off
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
914
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
915 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
916 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
917 { path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
918
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
919 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
920 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
921 ok(!grep ({ $_->{type} eq "DATA" } @$frames),
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
922 'proxy cache HEAD buffering off - no body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
923
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
924 # request body (uses proxied response)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
925
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
926 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
927 $sid = new_stream($sess, { path => '/proxy2/t2.html', body => 'TEST' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
928 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
929
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
930 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
931 is($frame->{headers}->{'x-body'}, 'TEST', 'request body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
932
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
933 # request body with padding (uses proxied response)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
934
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
935 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
936 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
937 { path => '/proxy2/t2.html', body => 'TEST', body_padding => 42 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
938 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
939
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
940 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
941 is($frame->{headers}->{'x-body'}, 'TEST', 'request body with padding');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
942
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
943 $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
944 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
945
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
946 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
947 is($frame->{headers}->{':status'}, '200', 'request body with padding - next');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
948
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
949 # initial window size, client side
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
950
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
951 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
952 # When an HTTP/2 connection is first established, new streams are
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
953 # 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
954 # The connection flow-control window is also 65,535 octets.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
955
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
956 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
957 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
958 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
959
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
960 # 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
961
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
962 @data = grep { $_->{type} eq "DATA" } @$frames;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
963 my $lengths = join ' ', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
964 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
965 'iws - stream blocked on initial window size');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
966
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
967 h2_ping($sess, 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
968 $frames = h2_read($sess, all => [{ type => 'PING' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
969
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
970 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
971 ok($frame, 'iws - PING not blocked');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
972
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
973 h2_window($sess, 2**16, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
974 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
975 is(@$frames, 0, 'iws - updated stream window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
976
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
977 h2_window($sess, 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
978 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
979
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
980 # with the default output_buffers, the remain data would be split
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
981 # on buffers boundary into separate data frames
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
982
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
983 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
984 my $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
985 is($sum, 81, 'iws - updated connection window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
986
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
987 # SETTINGS (initial window size, client side)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
988
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
989 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
990 # 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
991 # including a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
992 # frame that forms part of the connection preface. The connection
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
993 # flow-control window can only be changed using WINDOW_UPDATE frames.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
994
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
995 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
996 h2_settings($sess, 0, 0x4 => 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
997 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
998
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
999 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1000 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1001
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1002 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1003 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1004 is($sum, 2**16 + 80, 'iws - increased');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1005
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1006 # probe for negative available space in a flow control window
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1007
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1008 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1009 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1010 # 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
1011 # 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
1012 # controlled frames until it receives WINDOW_UPDATE frames that cause
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1013 # the flow-control window to become positive.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1014
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1015 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1016 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1017 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1018
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1019 h2_window($sess, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1020 h2_settings($sess, 0, 0x4 => 42);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1021 h2_window($sess, 1024, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1022
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1023 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1024
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1025 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1026 ok($frame, 'negative window - SETTINGS frame ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1027 is($frame->{flags}, 1, 'negative window - SETTINGS flags ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1028
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1029 ($frame) = grep { $_->{type} ne 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1030 is($frame, undef, 'negative window - no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1031
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1032 # predefined window size, minus new iws settings, minus window update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1033
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1034 h2_window($sess, 2**16 - 1 - 42 - 1024, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1035
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1036 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1037 is(@$frames, 0, 'zero window - no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1038
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1039 h2_window($sess, 1, $sid);
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 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1042 is(@$frames, 1, 'positive window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1043 is(@$frames[0]->{type}, 'DATA', 'positive window - data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1044 is(@$frames[0]->{length}, 1, 'positive window - data length');
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 # stream multiplexing + WINDOW_UPDATE
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1047
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1048 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1049 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1050 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1051
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1052 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1053 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1054 is($sum, 2**16 - 1, 'multiple - stream1 data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1055
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1056 my $sid2 = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1057 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1060 is(@data, 0, 'multiple - stream2 no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1061
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1062 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1063 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1064 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1065
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1066 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1067 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1068 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1069 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1070
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1071 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1072 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1073 is($sum, 81, 'multiple - stream1 remain data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1074
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1075 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1076 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1077 is($sum, 2**16 + 80, 'multiple - stream2 full data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1078
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1079 # stream muliplexing + PRIORITY frames
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1080
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1081 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1082 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1083 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1084
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1085 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1086 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1087
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1088 h2_priority($sess, 0, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1089 h2_priority($sess, 255, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1090
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1091 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1092 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1093 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1094
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1095 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1096 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1097 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1098 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1099
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1100 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1101 is(join(' ', map { $_->{sid} } @data), "$sid2 $sid", 'weight - PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1102
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1103 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1104
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1105 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1106 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1107 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1108
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1109 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1110 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1111
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1112 h2_priority($sess, 255, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1113 h2_priority($sess, 0, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1114
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1115 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1116 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1117 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1118
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1119 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1120 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1121 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1122 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1123
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1124 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1125 is(join(' ', map { $_->{sid} } @data), "$sid $sid2", 'weight - PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1126
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1127 # stream muliplexing + HEADERS PRIORITY flag
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1128
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1129 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1130 $sid = new_stream($sess, { path => '/t1.html', prio => 0 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1131 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1132
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1133 $sid2 = new_stream($sess, { path => '/t2.html', prio => 255 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1134 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1135
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1136 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1137 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1138 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1139
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1140 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1141 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1142 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1143 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1144
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1145 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1146 my $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1147 is($sids, "$sid2 $sid", 'weight - HEADERS PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1148
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1149 # and vice versa
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1152 $sid = new_stream($sess, { path => '/t1.html', prio => 255 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1153 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
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 $sid2 = new_stream($sess, { path => '/t2.html', prio => 0 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1156 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1157
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1158 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1159 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1160 h2_window($sess, 2**17);
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 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1163 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1164 { sid => $sid2, fin => 1 }
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1168 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1169 is($sids, "$sid $sid2", 'weight - HEADERS PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1170
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1171 # 5.3.1. Stream Dependencies
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1172
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1173 # PRIORITY frame
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1174
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1175 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1176
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1177 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1178 h2_priority($sess, 16, 1, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1179
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1180 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1181 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1182
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1183 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1184 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1185
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1186 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1187 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1188 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1189
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1190 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1191 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1192 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1193 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1194
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1195 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1196 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1197 is($sids, "$sid2 $sid", 'dependency - PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1198
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1199 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1200
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1201 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1202
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1203 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1204 h2_priority($sess, 16, 3, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1205
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1206 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1207 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1208
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1209 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1210 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1211
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1212 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1213 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1214 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1215
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1216 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1217 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1218 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1219 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1220
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1221 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1222 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1223 is($sids, "$sid $sid2", 'dependency - PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1224
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1225 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1226
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1227 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1228
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1229 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1230 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1231
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1232 $sid = new_stream($sess, { path => '/t1.html', dep => 3 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1233 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1234
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1235 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1236 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1237
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1238 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1239 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1240 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1241
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1242 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1243 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1244 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1245 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1246
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1247 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1248 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1249 is($sids, "$sid2 $sid", 'dependency - HEADERS PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1250
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1251 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1252
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1253 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1254
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1255 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1256 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1257
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1258 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1259 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1260
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1261 $sid2 = new_stream($sess, { path => '/t2.html', dep => 1 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1262 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1263
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1264 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1265 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1266 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1267
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1268 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1269 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1270 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1271 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1272
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1273 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1274 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1275 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1276
662
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1277 # PRIORITY frame, weighted dependencies
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1278
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1279 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1280
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1281 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1282 h2_priority($sess, 255, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1283 h2_priority($sess, 0, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1284
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1285 $sid = new_stream($sess, { path => '/t1.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1286 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1287
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1288 $sid2 = new_stream($sess, { path => '/t2.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1289 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1290
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1291 my $sid3 = new_stream($sess, { path => '/t2.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1292 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1293
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1294 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1295 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1296 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1297 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1298
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1299 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1300 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1301 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1302 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1303 ]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1304
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1305 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1306 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1307 is($sids, "$sid3 $sid $sid2", 'weighted dependency - PRIORITY 1');
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1308
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1309 # and vice versa
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1310
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1311 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1312
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1313 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1314 h2_priority($sess, 0, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1315 h2_priority($sess, 255, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1316
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1317 $sid = new_stream($sess, { path => '/t1.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1318 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1319
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1320 $sid2 = new_stream($sess, { path => '/t2.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1321 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1322
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1323 $sid3 = new_stream($sess, { path => '/t2.html' });
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1324 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1325
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1326 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1327 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1328 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1329 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1330
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1331 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1332 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1333 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1334 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1335 ]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1336
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1337 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1338 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1339 is($sids, "$sid3 $sid2 $sid", 'weighted dependency - PRIORITY 2');
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1340
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1341 # limit_conn
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1342
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1343 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1344 h2_settings($sess, 0, 0x4 => 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1345
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1346 $sid = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1347 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1348
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1349 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1350 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1351
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1352 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1353 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1354
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1355 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1356 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1357
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1358 h2_settings($sess, 0, 0x4 => 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1359
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1360 h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1361 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1362 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1363 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1364
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1365 # limit_conn + client's RST_STREAM
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1366
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1367 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1368 h2_settings($sess, 0, 0x4 => 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1369
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1370 $sid = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1371 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1372 h2_rst($sess, $sid, 5);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1373
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1374 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1375 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1376
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1377 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1378 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1379
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1380 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1381 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1382
654
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1383 # http2_max_concurrent_streams
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1384
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1385 $sess = new_session(8086);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1386 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1387
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1388 ($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
1389 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
1390
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1391 h2_window($sess, 2**18);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1392
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1393 $sid = new_stream($sess, { path => '/t1.html' });
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1394 $frames = h2_read($sess, all => [{ sid => $sid, length => 2 ** 16 - 1 }]);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1395
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1396 ($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
1397 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
1398
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1399 $sid2 = new_stream($sess, { path => '/t1.html' });
667
0247e314e991 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 662
diff changeset
1400 $frames = h2_read($sess, 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
1401
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1402 ($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
1403 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
1404
667
0247e314e991 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 662
diff changeset
1405 ($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
1406 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
1407 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
1408 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
1409 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
1410
661
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1411 h2_window($sess, 2**16, $sid);
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1412 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1413
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1414 $sid = new_stream($sess, { path => '/t2.html' });
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1415 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1416
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1417 ($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
1418 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
1419
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1420
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1421 # some invalid cases below
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1422
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1423 # ensure that request header field value with newline doesn't get split
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1424 #
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1425 # 10.3. Intermediary Encapsulation Attacks
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1426 # Any request or response that contains a character not permitted
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1427 # in a header field value MUST be treated as malformed.
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1428
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1429 $sess = new_session();
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1430 $sid = new_stream($sess, { headers => [
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1431 { name => ':method', value => 'GET', mode => 0 },
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1432 { name => ':scheme', value => 'http', mode => 0 },
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1433 { name => ':path', value => '/proxy2/', mode => 1 },
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1434 { name => ':authority', value => 'localhost', mode => 1 },
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1435 { name => 'x-foo', value => "x-bar\r\nreferer:see-this", mode => 2 }]});
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1436 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1437
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1438 # 10.3. Intermediary Encapsulation Attacks
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1439 # An intermediary therefore cannot translate an HTTP/2 request or response
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1440 # containing an invalid field name into an HTTP/1.1 message.
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1441
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1442 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1443 isnt($frame->{headers}->{'x-referer'}, 'see-this', 'newline in request header');
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
1444
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1445 # 8.1.2.6. Malformed Requests and Responses
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1446 # For malformed requests, a server MAY send an HTTP response prior to
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1447 # closing or resetting the stream.
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1448
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1449 is($frame->{headers}->{':status'}, 400, 'newline in request header - status');
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1450
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1451 # 8.1.2.6. Malformed Requests and Responses
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1452 # Malformed requests or responses that are detected MUST be treated
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1453 # as a stream error (Section 5.4.2) of type PROTOCOL_ERROR.
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1454
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1455 TODO: {
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1456 local $TODO = 'not yet';
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1457
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1458 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1459 is($frame->{sid}, $sid, 'newline in request header - RST_STREAM sid');
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1460 is($frame->{length}, 4, 'newline in request header - RST_STREAM length');
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1461 is($frame->{flags}, 0, 'newline in request header - RST_STREAM flags');
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1462 is($frame->{code}, 1, 'newline in request header - RST_STREAM code');
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1463
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1464 }
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
1465
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1466 # GOAWAY on SYN_STREAM with even StreamID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1467
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1468 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1469 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1470
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1471 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1472 new_stream($sess, { path => '/' }, 2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1473 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1474
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1475 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1476 ok($frame, 'even stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1477 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
1478 is($frame->{last_sid}, 0, 'even stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1479
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1480 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1481
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1482 # GOAWAY on SYN_STREAM with backward StreamID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1483
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1484 # 5.1.1. Stream Identifiers
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1485 # 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
1486 # 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
1487
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1488 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1489 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1490
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1491 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1492 $sid = new_stream($sess, { path => '/' }, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1493 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1494
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1495 $sid2 = new_stream($sess, { path => '/' }, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1496 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1497
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1498 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1499 ok($frame, 'backward stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1500 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
1501 is($frame->{last_sid}, $sid, 'backward stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1502
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1503 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1504
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1505 # GOAWAY on the second SYN_STREAM with same StreamID
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1506
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1507 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1508 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1509
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1510 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1511 $sid = new_stream($sess, { path => '/' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1512 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1513
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1514 $sid2 = new_stream($sess, { path => '/' }, $sid);
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1515 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1516
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1517 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
1518 ok($frame, 'dup stream - GOAWAY frame');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1519 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
1520 is($frame->{last_sid}, $sid, 'dup stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1521
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1522 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1523
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1524 # missing mandatory request header ':scheme'
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1525
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1526 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1527 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1528
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1529 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1530 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1531 { name => ':method', value => 'GET', mode => 0 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
1532 { 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
1533 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1534 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1535
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1536 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1537 is($frame->{headers}->{':status'}, 400, 'incomplete headers');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1538
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1539 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1540
673
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1541 # empty request header ':authority'
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1542
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1543 $sess = new_session();
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1544 $sid = new_stream($sess, { headers => [
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1545 { name => ':method', value => 'GET', mode => 0 },
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1546 { name => ':scheme', value => 'http', mode => 0 },
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1547 { name => ':path', value => '/', mode => 0 },
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1548 { name => ':authority', value => '', mode => 0 }]});
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1549 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1550
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1551 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1552 is($frame->{headers}->{':status'}, 400, 'empty authority');
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
1553
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1554 # GOAWAY - force closing a connection by server
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1555
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1556 $sid = new_stream($sess, { path => 't1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1557 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1558
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1559 $t->stop();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1560
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1561 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1562 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1563
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1564 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1565
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1566 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1567 ok($frame, 'GOAWAY on connection close');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1568
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1569 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1570
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1571 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1572
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1573 sub h2_ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1574 my ($sess, $payload) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1575
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1576 raw_write($sess->{socket}, pack("x2C2x5a8", 8, 0x6, $payload));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1577 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1578
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1579 sub h2_rst {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1580 my ($sess, $stream, $error) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1581
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1582 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1583 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1584
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1585 sub h2_priority {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1586 my ($sess, $w, $stream, $dep) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1587
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1588 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1589 $dep = 0 unless defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1590 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1591 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1592
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1593 sub h2_window {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1594 my ($sess, $win, $stream) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1595
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1596 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1597 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x8, $stream, $win));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1598 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1599
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1600 sub h2_settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1601 my ($sess, $ack, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1602
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1603 my $len = 6 * keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1604 my $buf = pack_length($len) . pack "CCx4", 0x4, $ack ? 0x1 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1605 $buf .= join '', map { pack "nN", $_, $extra{$_} } keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1606 raw_write($sess->{socket}, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1607 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1608
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1609 sub h2_continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1610 my ($ctx, $stream, $uri) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1611
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1612 $uri->{h2_continue} = 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1613 return new_stream($ctx, $uri, $stream);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1614 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1615
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1616 sub new_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1617 my ($ctx, $uri, $stream) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1618 my ($input, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1619 my ($d, $status);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1620
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1621 my $host = $uri->{host} || '127.0.0.1:8080';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1622 my $method = $uri->{method} || 'GET';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1623 my $scheme = $uri->{scheme} || 'http';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1624 my $path = $uri->{path} || '/';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1625 my $headers = $uri->{headers};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1626 my $body = $uri->{body};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1627 my $prio = $uri->{prio};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1628 my $dep = $uri->{dep};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1629
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1630 my $pad = defined $uri->{padding} ? $uri->{padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1631 my $padlen = defined $uri->{padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1632 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1633 my $bpadlen = defined $uri->{body_padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1634
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1635 my $type = defined $uri->{h2_continue} ? 0x9 : 0x1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1636 my $flags = defined $uri->{continuation} ? 0x0 : 0x4;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1637 $flags |= 0x1 unless defined $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1638 $flags |= 0x8 if $padlen;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1639 $flags |= 0x20 if defined $dep || defined $prio;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1640
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1641 if ($stream) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1642 $ctx->{last_stream} = $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1643 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1644 $ctx->{last_stream} += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1645 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1647 $buf = pack("xxx"); # Length stub
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1648 $buf .= pack("CC", $type, $flags); # END_HEADERS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1649 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1650
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1651 $dep = 0 if defined $prio and not defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1652 $prio = 16 if defined $dep and not defined $prio;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1653
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1654 unless ($headers) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1655 $input = hpack($ctx, ":method", $method);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1656 $input .= hpack($ctx, ":scheme", $scheme);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1657 $input .= hpack($ctx, ":path", $path);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1658 $input .= hpack($ctx, ":authority", $host);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1659 $input .= hpack($ctx, "content-length", length($body)) if $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1660
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1661 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1662 $input = join '', map {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1663 hpack($ctx, $_->{name}, $_->{value},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1664 mode => $_->{mode}, huff => $_->{huff})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1665 } @$headers if $headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1666 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1667
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1668 # 5.1. Integer Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1669
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1670 sub intpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1671 my $d = shift;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1672 return pack('B8', '001' . sprintf("%5b", $d)) if $d < 31;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1673
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1674 my $o = '00111111';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1675 $d -= 31;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1676 while ($d >= 128) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1677 $o .= sprintf("%8b", $d % 128 + 128);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1678 $d /= 128;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1679 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1680 $o .= sprintf("%08b", $d);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1681 return pack('B*', $o);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1682 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1683
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1684 $input = intpack($uri->{table_size}) . $input
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1685 if defined $uri->{table_size};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1686
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1687 # set length, attach headers, padding, priority
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1688
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1689 my $hlen = length($input) + $pad + $padlen;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1690 $hlen += 5 if $flags & 0x20;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1691 $buf |= pack_length($hlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1692
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1693 $buf .= pack 'C', $pad if $padlen; # Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1694 $buf .= pack 'NC', $dep, $prio if $flags & 0x20;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1695 $buf .= $input;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1696 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1697
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1698 if (defined $body) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1699 $buf .= pack_length(length($body) + $bpad + $bpadlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1700 my $flags = $bpadlen ? 0x8 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1701 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1702 $buf .= pack 'N', $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1703 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1704 $buf .= $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1705 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1706 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1707
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1708 raw_write($ctx->{socket}, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1709 return $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1710 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1711
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1712 sub h2_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1713 my ($sess, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1714 my (@got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1715 my $s = $sess->{socket};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1716 my $buf = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1717
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1718 while (1) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1719 $buf = raw_read($s, $buf, 9);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1720 last unless length $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1721
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1722 my $length = unpack_length($buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1723 my $type = unpack('x3C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1724 my $flags = unpack('x4C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1725
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1726 my $stream = unpack "x5 B32", $buf;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1727 substr($stream, 0, 1) = 0;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1728 $stream = unpack("N", pack("B32", $stream));
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1729
679
b60c1a207675 Tests: fixed HTTP/2 tests with large frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 677
diff changeset
1730 $buf = raw_read($s, $buf, $length + 9);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1731 last unless length $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1732
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1733 $buf = substr($buf, 9);
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1734
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1735 my $frame = $cframe{$type}{value}($sess, $buf, $length);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1736 $frame->{length} = $length;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1737 $frame->{type} = $cframe{$type}{name};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1738 $frame->{flags} = $flags;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1739 $frame->{sid} = $stream;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1740 push @got, $frame;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1741
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1742 $buf = substr($buf, $length);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1743
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1744 last unless test_fin($got[-1], $extra{all});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1745 };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1746 return \@got;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1747 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1748
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1749 sub test_fin {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1750 my ($frame, $all) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1751 my @test = @{$all};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1752
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1753 # wait for the specified DATA length
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1754
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1755 for (@test) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1756 if ($_->{length} && $frame->{type} eq 'DATA') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1757 # check also for StreamID if needed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1758
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1759 if (!$_->{sid} || $_->{sid} == $frame->{sid}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1760 $_->{length} -= $frame->{length};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1761 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1762 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1763 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1764 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1765
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1766 # wait for the fin flag
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1767
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1768 @test = grep { !(defined $_->{fin}
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1769 && $_->{sid} == $frame->{sid} && $_->{fin} & $frame->{flags})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1770 } @test if defined $frame->{flags};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1771
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1772 # wait for the specified frame
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1773
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1774 @test = grep { !($_->{type} && $_->{type} eq $frame->{type}) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1775
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1776 @{$all} = @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1777 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1778
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1779 sub headers {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1780 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1781 return { headers => hunpack($ctx, $buf, $len) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1782 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1783
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1784 sub data {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1785 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1786 return { data => substr($buf, 0, $len) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1787 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1788
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1789 sub settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1790 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1791 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1792 my $skip = 0;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1793
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1794 for (1 .. $len / 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1795 my $id = hex unpack "\@$skip n", $buf; $skip += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1796 $payload{$id} = unpack "\@$skip N", $buf; $skip += 4;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1797 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1798 return \%payload;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1799 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1800
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1801 sub ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1802 my ($ctx, $buf, $len) = @_;
670
944b87756cab Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 669
diff changeset
1803 return { value => unpack "A$len", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1804 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1805
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1806 sub rst_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1807 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1808 return { code => unpack "N", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1809 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1810
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1811 sub goaway {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1812 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1813 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1814
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1815 my $stream = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1816 substr($stream, 0, 1) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1817 $stream = unpack("N", pack("B32", $stream));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1818 $payload{last_sid} = $stream;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1819
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1820 $len -= 4;
670
944b87756cab Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 669
diff changeset
1821 $payload{code} = unpack "x4 N", $buf;
944b87756cab Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 669
diff changeset
1822 $payload{debug} = unpack "x8 A$len", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1823 return \%payload;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1824 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1825
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1826 sub window_update {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1827 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1828 my $value = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1829 substr($value, 0, 1) = 0;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
1830 return { wdelta => unpack("N", pack("B32", $value)) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1831 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1832
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1833 sub pack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1834 pack 'c3', unpack 'xc3', pack 'N', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1835 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1836
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1837 sub unpack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1838 unpack 'N', pack 'xc3', unpack 'c3', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1839 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1840
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1841 sub raw_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1842 my ($s, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1843 my $got = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1844
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1845 while (length($buf) < $len && IO::Select->new($s)->can_read(1)) {
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1846 $s->sysread($got, 16384) or last;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1847 log_in($got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1848 $buf .= $got;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1849 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1850 return $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1851 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1852
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1853 sub raw_write {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1854 my ($s, $message) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1855
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1856 local $SIG{PIPE} = 'IGNORE';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1857
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1858 while (IO::Select->new($s)->can_write(0.4)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1859 log_out($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1860 my $n = $s->syswrite($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1861 last unless $n;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1862 $message = substr($message, $n);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1863 last unless length $message;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1864 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1865 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1866
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1867 sub new_session {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1868 my ($port, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1869 my ($s);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1870
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1871 $s = new_socket($port, %extra);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1872
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1873 if ($extra{proxy}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1874 raw_write($s, $extra{proxy});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1875 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1876
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1877 # preface
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1878
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1879 raw_write($s, 'PRI * HTTP/2.0' . CRLF . CRLF . 'SM' . CRLF . CRLF);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1880
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1881 return { socket => $s, last_stream => -1,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1882 dynamic_encode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1883 dynamic_decode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1884 static_table_size => scalar @{[static_table()]} };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1885 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1886
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1887 sub new_socket {
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1888 my ($port, %extra) = @_;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1889 my $npn = $extra{'npn'};
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1890 my $alpn = $extra{'alpn'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1891 my $s;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1892
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1893 $port = 8080 unless defined $port;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1894
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1895 eval {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1896 local $SIG{ALRM} = sub { die "timeout\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1897 local $SIG{PIPE} = sub { die "sigpipe\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1898 alarm(2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1899 $s = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1900 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1901 PeerAddr => "127.0.0.1:$port",
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1902 );
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1903 IO::Socket::SSL->start_SSL($s,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1904 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1905 SSL_npn_protocols => $npn ? [ $npn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1906 SSL_alpn_protocols => $alpn ? [ $alpn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1907 SSL_error_trap => sub { die $_[1] }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
1908 ) if $extra{'SSL'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1909 alarm(0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1910 };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1911 alarm(0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1912
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1913 if ($@) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1914 log_in("died: $@");
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1915 return undef;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1916 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1917
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1918 return $s;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1919 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1920
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1921 sub static_table {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1922 [ '', '' ], # unused
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1923 [ ':authority', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1924 [ ':method', 'GET' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1925 [ ':method', 'POST' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1926 [ ':path', '/' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1927 [ ':path', '/index.html' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1928 [ ':scheme', 'http' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1929 [ ':scheme', 'https' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1930 [ ':status', '200' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1931 [ ':status', '204' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1932 [ ':status', '206' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1933 [ ':status', '304' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1934 [ ':status', '400' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1935 [ ':status', '404' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1936 [ ':status', '500' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1937 [ 'accept-charset', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1938 [ 'accept-encoding', 'gzip, deflate' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1939 [ 'accept-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1940 [ 'accept-ranges', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1941 [ 'accept', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1942 [ 'access-control-allow-origin',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1943 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1944 [ 'age', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1945 [ 'allow', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1946 [ 'authorization', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1947 [ 'cache-control', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1948 [ 'content-disposition',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1949 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1950 [ 'content-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1951 [ 'content-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1952 [ 'content-length', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1953 [ 'content-location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1954 [ 'content-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1955 [ 'content-type', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1956 [ 'cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1957 [ 'date', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1958 [ 'etag', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1959 [ 'expect', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1960 [ 'expires', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1961 [ 'from', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1962 [ 'host', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1963 [ 'if-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1964 [ 'if-modified-since', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1965 [ 'if-none-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1966 [ 'if-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1967 [ 'if-unmodified-since',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1968 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1969 [ 'last-modified', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1970 [ 'link', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1971 [ 'location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1972 [ 'max-forwards', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1973 [ 'proxy-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1974 [ 'proxy-authorization',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1975 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1976 [ 'range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1977 [ 'referer', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1978 [ 'refresh', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1979 [ 'retry-after', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1980 [ 'server', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1981 [ 'set-cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1982 [ 'strict-transport-security',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1983 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1984 [ 'transfer-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1985 [ 'user-agent', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1986 [ 'vary', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1987 [ 'via', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1988 [ 'www-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1989 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1990
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1991 sub hpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1992 my ($ctx, $name, $value, %extra) = @_;
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
1993 my $table = $ctx->{dynamic_encode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1994 my $mode = defined $extra{mode} ? $extra{mode} : 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1995 my $huff = $extra{huff};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1996
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1997 my ($index, $buf) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1998
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1999 # 6.1. Indexed Header Field Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2000
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2001 if ($mode == 0) {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2002 ++$index until $index > $#$table
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2003 or $table->[$index][0] eq $name
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2004 and $table->[$index][1] eq $value;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2005 $buf = pack('B*', '1' . sprintf("%7b", $index));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2006 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2007
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2008 # 6.2.1. Literal Header Field with Incremental Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2009
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2010 if ($mode == 1) {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2011 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ];
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2012
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2013 ++$index until $index > $#$table
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2014 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2015 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2016
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2017 $buf = pack('B*', '01' . sprintf("%6b", $index)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2018 . ($huff ? '1' : '0') . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2019 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2020 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2021
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2022 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2023
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2024 if ($mode == 2) {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2025 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2026
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2027 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2028 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2029 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2030
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2031 $buf = pack('B*', '01000000');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2032 $buf .= pack('B*', $hbit . sprintf("%7b", length($name)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2033 $buf .= $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2034 $buf .= pack('B*', $hbit . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2035 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2036 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2037
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2038 # 6.2.2. Literal Header Field without Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2039
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2040 if ($mode == 3) {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2041 ++$index until $index > $#$table
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2042 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2043 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2044
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2045 $buf = pack('B*', '0000' . sprintf("%4b", $index)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2046 . ($huff ? '1' : '0') . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2047 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2048 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2049
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2050 # 6.2.2. Literal Header Field without Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2051
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2052 if ($mode == 4) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2053 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2054 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2055 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2056
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2057 $buf = pack('B*', '00000000');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2058 $buf .= pack('B*', $hbit . sprintf("%7b", length($name)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2059 $buf .= $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2060 $buf .= pack('B*', $hbit . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2061 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2062 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2063
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2064 # 6.2.3. Literal Header Field Never Indexed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2065
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2066 if ($mode == 5) {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2067 ++$index until $index > $#$table
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2068 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2069 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2070
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2071 $buf = pack('B*', '0001' . sprintf("%4b", $index)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2072 . ($huff ? '1' : '0') . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2073 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2074 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2075
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2076 # 6.2.3. Literal Header Field Never Indexed -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2077
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2078 if ($mode == 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2079 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2080 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2081 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2082
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2083 $buf = pack('B*', '00010000');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2084 $buf .= pack('B*', $hbit . sprintf("%7b", length($name)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2085 $buf .= $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2086 $buf .= pack('B*', $hbit . sprintf("%7b", length($value)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2087 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2088 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2089
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2090 return $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2091 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2092
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2093 sub hunpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2094 my ($ctx, $data, $length) = @_;
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2095 my $table = $ctx->{dynamic_decode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2096 my %headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2097 my $skip = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2098 my ($name, $value);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2099
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2100 sub index {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2101 my ($b, $i) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2102 unpack("C", pack("B8", '0' x $i . substr($b, $i, 8 - $i)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2103 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2104
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2105 sub field {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2106 my ($b, $s) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2107 my $len = unpack("\@$s B8", $b);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2108 my $huff = substr($len, 0, 1) ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2109 $len = unpack("C", pack("B8", '0' . substr($len, 1, 8)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2110 $s++;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2111
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2112 my $field = substr($b, $s, $len);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2113 $field = $huff ? dehuff($field) : $field;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2114 $s += $len;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2115 return ($field, $s);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2116 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2117
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2118 sub add {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2119 my ($h, $n, $v) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2120 return $h->{$n} = $v unless exists $h->{$n};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2121 $h->{$n} = [ $h->{$n} ];
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
2122 push @{$h->{$n}}, $v;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2123 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2124
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2125 while ($skip < $length) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2126 my $ib = unpack("\@$skip B8", $data);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2127
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2128 if (substr($ib, 0, 1) eq '1') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2129 my $index = &index($ib, 1);
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2130 add(\%headers,
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2131 $table->[$index][0], $table->[$index][1]);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2132 $skip += 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2133 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2134 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2135
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2136 if (substr($ib, 0, 2) eq '01') {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2137 $name = $table->[&index($ib, 2)][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2138 $skip++;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2139
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2140 ($name, $skip) = field($data, $skip) unless $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2141 ($value, $skip) = field($data, $skip);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2142
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2143 splice @$table,
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2144 $ctx->{static_table_size}, 0, [ $name, $value ];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2145 add(\%headers, $name, $value);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2146 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2147 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2148
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2149 if (substr($ib, 0, 4) eq '0000') {
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2150 $name = $table->[&index($ib, 4)][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2151 $skip++;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2152
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2153 ($name, $skip) = field($data, $skip) unless $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2154 ($value, $skip) = field($data, $skip);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2155
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2156 add(\%headers, $name, $value);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2157 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2158 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2159 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2160
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2161 return \%headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2162 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2163
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2164 sub huff_code { scalar {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2165 pack('C', 0) => '1111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2166 pack('C', 1) => '11111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2167 pack('C', 2) => '1111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2168 pack('C', 3) => '1111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2169 pack('C', 4) => '1111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2170 pack('C', 5) => '1111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2171 pack('C', 6) => '1111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2172 pack('C', 7) => '1111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2173 pack('C', 8) => '1111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2174 pack('C', 9) => '111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2175 pack('C', 10) => '111111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2176 pack('C', 11) => '1111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2177 pack('C', 12) => '1111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2178 pack('C', 13) => '111111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2179 pack('C', 14) => '1111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2180 pack('C', 15) => '1111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2181 pack('C', 16) => '1111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2182 pack('C', 17) => '1111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2183 pack('C', 18) => '1111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2184 pack('C', 19) => '1111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2185 pack('C', 20) => '1111111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2186 pack('C', 21) => '1111111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2187 pack('C', 22) => '111111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2188 pack('C', 23) => '1111111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2189 pack('C', 24) => '1111111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2190 pack('C', 25) => '1111111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2191 pack('C', 26) => '1111111111111111111111110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2192 pack('C', 27) => '1111111111111111111111110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2193 pack('C', 28) => '1111111111111111111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2194 pack('C', 29) => '1111111111111111111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2195 pack('C', 30) => '1111111111111111111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2196 pack('C', 31) => '1111111111111111111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2197 pack('C', 32) => '010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2198 pack('C', 33) => '1111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2199 pack('C', 34) => '1111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2200 pack('C', 35) => '111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2201 pack('C', 36) => '1111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2202 pack('C', 37) => '010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2203 pack('C', 38) => '11111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2204 pack('C', 39) => '11111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2205 pack('C', 40) => '1111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2206 pack('C', 41) => '1111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2207 pack('C', 42) => '11111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2208 pack('C', 43) => '11111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2209 pack('C', 44) => '11111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2210 pack('C', 45) => '010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2211 pack('C', 46) => '010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2212 pack('C', 47) => '011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2213 pack('C', 48) => '00000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2214 pack('C', 49) => '00001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2215 pack('C', 50) => '00010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2216 pack('C', 51) => '011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2217 pack('C', 52) => '011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2218 pack('C', 53) => '011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2219 pack('C', 54) => '011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2220 pack('C', 55) => '011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2221 pack('C', 56) => '011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2222 pack('C', 57) => '011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2223 pack('C', 58) => '1011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2224 pack('C', 59) => '11111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2225 pack('C', 60) => '111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2226 pack('C', 61) => '100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2227 pack('C', 62) => '111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2228 pack('C', 63) => '1111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2229 pack('C', 64) => '1111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2230 pack('C', 65) => '100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2231 pack('C', 66) => '1011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2232 pack('C', 67) => '1011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2233 pack('C', 68) => '1011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2234 pack('C', 69) => '1100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2235 pack('C', 70) => '1100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2236 pack('C', 71) => '1100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2237 pack('C', 72) => '1100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2238 pack('C', 73) => '1100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2239 pack('C', 74) => '1100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2240 pack('C', 75) => '1100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2241 pack('C', 76) => '1100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2242 pack('C', 77) => '1101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2243 pack('C', 78) => '1101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2244 pack('C', 79) => '1101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2245 pack('C', 80) => '1101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2246 pack('C', 81) => '1101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2247 pack('C', 82) => '1101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2248 pack('C', 83) => '1101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2249 pack('C', 84) => '1101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2250 pack('C', 85) => '1110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2251 pack('C', 86) => '1110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2252 pack('C', 87) => '1110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2253 pack('C', 88) => '11111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2254 pack('C', 89) => '1110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2255 pack('C', 90) => '11111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2256 pack('C', 91) => '1111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2257 pack('C', 92) => '1111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2258 pack('C', 93) => '1111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2259 pack('C', 94) => '11111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2260 pack('C', 95) => '100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2261 pack('C', 96) => '111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2262 pack('C', 97) => '00011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2263 pack('C', 98) => '100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2264 pack('C', 99) => '00100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2265 pack('C', 100) => '100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2266 pack('C', 101) => '00101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2267 pack('C', 102) => '100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2268 pack('C', 103) => '100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2269 pack('C', 104) => '100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2270 pack('C', 105) => '00110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2271 pack('C', 106) => '1110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2272 pack('C', 107) => '1110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2273 pack('C', 108) => '101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2274 pack('C', 109) => '101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2275 pack('C', 110) => '101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2276 pack('C', 111) => '00111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2277 pack('C', 112) => '101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2278 pack('C', 113) => '1110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2279 pack('C', 114) => '101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2280 pack('C', 115) => '01000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2281 pack('C', 116) => '01001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2282 pack('C', 117) => '101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2283 pack('C', 118) => '1110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2284 pack('C', 119) => '1111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2285 pack('C', 120) => '1111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2286 pack('C', 121) => '1111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2287 pack('C', 122) => '1111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2288 pack('C', 123) => '111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2289 pack('C', 124) => '11111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2290 pack('C', 125) => '11111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2291 pack('C', 126) => '1111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2292 pack('C', 127) => '1111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2293 pack('C', 128) => '11111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2294 pack('C', 129) => '1111111111111111010010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2295 pack('C', 130) => '11111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2296 pack('C', 131) => '11111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2297 pack('C', 132) => '1111111111111111010011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2298 pack('C', 133) => '1111111111111111010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2299 pack('C', 134) => '1111111111111111010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2300 pack('C', 135) => '11111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2301 pack('C', 136) => '1111111111111111010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2302 pack('C', 137) => '11111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2303 pack('C', 138) => '11111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2304 pack('C', 139) => '11111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2305 pack('C', 140) => '11111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2306 pack('C', 141) => '11111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2307 pack('C', 142) => '111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2308 pack('C', 143) => '11111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2309 pack('C', 144) => '111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2310 pack('C', 145) => '111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2311 pack('C', 146) => '1111111111111111010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2312 pack('C', 147) => '11111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2313 pack('C', 148) => '111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2314 pack('C', 149) => '11111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2315 pack('C', 150) => '11111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2316 pack('C', 151) => '11111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2317 pack('C', 152) => '11111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2318 pack('C', 153) => '111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2319 pack('C', 154) => '1111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2320 pack('C', 155) => '11111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2321 pack('C', 156) => '1111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2322 pack('C', 157) => '11111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2323 pack('C', 158) => '11111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2324 pack('C', 159) => '111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2325 pack('C', 160) => '1111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2326 pack('C', 161) => '111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2327 pack('C', 162) => '11111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2328 pack('C', 163) => '1111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2329 pack('C', 164) => '1111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2330 pack('C', 165) => '11111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2331 pack('C', 166) => '11111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2332 pack('C', 167) => '111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2333 pack('C', 168) => '11111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2334 pack('C', 169) => '1111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2335 pack('C', 170) => '1111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2336 pack('C', 171) => '111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2337 pack('C', 172) => '111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2338 pack('C', 173) => '1111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2339 pack('C', 174) => '11111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2340 pack('C', 175) => '11111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2341 pack('C', 176) => '111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2342 pack('C', 177) => '111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2343 pack('C', 178) => '1111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2344 pack('C', 179) => '111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2345 pack('C', 180) => '11111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2346 pack('C', 181) => '1111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2347 pack('C', 182) => '11111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2348 pack('C', 183) => '11111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2349 pack('C', 184) => '11111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2350 pack('C', 185) => '1111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2351 pack('C', 186) => '1111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2352 pack('C', 187) => '1111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2353 pack('C', 188) => '11111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2354 pack('C', 189) => '1111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2355 pack('C', 190) => '1111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2356 pack('C', 191) => '11111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2357 pack('C', 192) => '11111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2358 pack('C', 193) => '11111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2359 pack('C', 194) => '11111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2360 pack('C', 195) => '1111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2361 pack('C', 196) => '1111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2362 pack('C', 197) => '11111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2363 pack('C', 198) => '1111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2364 pack('C', 199) => '1111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2365 pack('C', 200) => '11111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2366 pack('C', 201) => '11111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2367 pack('C', 202) => '11111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2368 pack('C', 203) => '111111111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2369 pack('C', 204) => '111111111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2370 pack('C', 205) => '11111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2371 pack('C', 206) => '111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2372 pack('C', 207) => '1111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2373 pack('C', 208) => '1111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2374 pack('C', 209) => '111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2375 pack('C', 210) => '11111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2376 pack('C', 211) => '111111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2377 pack('C', 212) => '111111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2378 pack('C', 213) => '11111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2379 pack('C', 214) => '111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2380 pack('C', 215) => '111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2381 pack('C', 216) => '111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2382 pack('C', 217) => '111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2383 pack('C', 218) => '11111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2384 pack('C', 219) => '11111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2385 pack('C', 220) => '1111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2386 pack('C', 221) => '111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2387 pack('C', 222) => '111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2388 pack('C', 223) => '111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2389 pack('C', 224) => '11111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2390 pack('C', 225) => '111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2391 pack('C', 226) => '11111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2392 pack('C', 227) => '111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2393 pack('C', 228) => '1111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2394 pack('C', 229) => '111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2395 pack('C', 230) => '111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2396 pack('C', 231) => '11111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2397 pack('C', 232) => '1111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2398 pack('C', 233) => '1111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2399 pack('C', 234) => '1111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2400 pack('C', 235) => '1111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2401 pack('C', 236) => '111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2402 pack('C', 237) => '111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2403 pack('C', 238) => '11111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2404 pack('C', 239) => '11111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2405 pack('C', 240) => '11111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2406 pack('C', 241) => '111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2407 pack('C', 242) => '11111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2408 pack('C', 243) => '11111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2409 pack('C', 244) => '111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2410 pack('C', 245) => '111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2411 pack('C', 246) => '111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2412 pack('C', 247) => '111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2413 pack('C', 248) => '111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2414 pack('C', 249) => '1111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2415 pack('C', 250) => '111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2416 pack('C', 251) => '111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2417 pack('C', 252) => '111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2418 pack('C', 253) => '111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2419 pack('C', 254) => '111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2420 pack('C', 255) => '11111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2421 '_eos' => '111111111111111111111111111111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2422 }};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2423
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2424 sub huff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2425 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2426 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2427
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2428 my $ret = join '', map { $code->{$_} } (split //, $string);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2429 my $len = length($ret) + (8 - length($ret) % 8);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2430 $ret .= $code->{_eos};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2431
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2432 return pack("B$len", $ret);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2433 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2434
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2435 sub dehuff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2436 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2437 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2438 my %decode = reverse %$code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2439
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2440 my $ret = ''; my $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2441 for (split //, unpack('B*', $string)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2442 $c .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2443 next unless exists $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2444 last if $decode{$c} eq '_eos';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2445
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2446 $ret .= $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2447 $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2448 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2449
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2450 return $ret;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2451 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2452
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2453 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2454
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
2455 sub gunzip_like {
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
2456 my ($in, $re, $name) = @_;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2457
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2458 SKIP: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2459 eval { require IO::Uncompress::Gunzip; };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2460 Test::More::skip(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2461 "IO::Uncompress::Gunzip not installed", 1) if $@;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2462
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2463 my $out;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2464
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2465 IO::Uncompress::Gunzip::gunzip(\$in => \$out);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2466
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
2467 like($out, $re, $name);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2468 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2469 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2470
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2471 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2472
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2473 # for tests with multiple header fields
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2474
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2475 sub http_daemon {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2476 my $server = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2477 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2478 LocalHost => '127.0.0.1',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2479 LocalPort => 8083,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2480 Listen => 5,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2481 Reuse => 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2482 )
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2483 or die "Can't create listening socket: $!\n";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2484
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2485 local $SIG{PIPE} = 'IGNORE';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2486
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2487 while (my $client = $server->accept()) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2488 $client->autoflush(1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2489
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2490 my $headers = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2491 my $uri = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2492
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2493 while (<$client>) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2494 $headers .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2495 last if (/^\x0d?\x0a?$/);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2496 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2497
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2498 next if $headers eq '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2499 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2500
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2501 if ($uri eq '/cookie') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2502
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2503 my ($cookie, $cookie2) = $headers =~ /Cookie: (.+)/ig;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2504 $cookie2 = '' unless defined $cookie2;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2505
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2506 my ($cookie_a, $cookie_c) = ('', '');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2507 $cookie_a = $1 if $headers =~ /X-Cookie-a: (.+)/i;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2508 $cookie_c = $1 if $headers =~ /X-Cookie-c: (.+)/i;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2509
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2510 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2511 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2512 Connection: close
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2513 X-Sent-Cookie: $cookie
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2514 X-Sent-Cookie2: $cookie2
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2515 X-Sent-Cookie-a: $cookie_a
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
2516 X-Sent-Cookie-c: $cookie_c
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2517
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2518 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2519
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2520 } elsif ($uri eq '/set-cookie') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2521
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2522 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2523 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2524 Connection: close
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2525 Set-Cookie: a=b
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2526 Set-Cookie: c=d
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2527
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2528 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2529
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2530 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2531
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2532 } continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2533 close $client;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2534 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2535 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2536
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2537 ###############################################################################