annotate h2.t @ 737:abf42eb6cf48

Tests: HTTP/2 test for indexed header field name in dynamic table.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 19 Oct 2015 17:02:20 +0300
parents dcbe4c3d6871
children 0881219c0699
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/)
737
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
35 ->has_daemon('openssl')->plan(223);
704
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
36
730
63c45a158cde Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 729
diff changeset
37 # Some systems have a bug in not treating zero writev iovcnt as EINVAL
63c45a158cde Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 729
diff changeset
38
63c45a158cde Tests: adjusted todo_alerts() in h2.t and spdy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 729
diff changeset
39 $t->todo_alerts() if $^O eq 'darwin';
646
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 $t->write_file_expand('nginx.conf', <<'EOF');
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 %%TEST_GLOBALS%%
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 daemon off;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 events {
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 http {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 %%TEST_GLOBALS_HTTP%%
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 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 limit_conn_zone $binary_remote_addr zone=conn:1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 listen 127.0.0.1:8080 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 listen 127.0.0.1:8081;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 listen 127.0.0.1:8082 proxy_protocol http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 listen 127.0.0.1:8084 http2 ssl;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 server_name localhost;
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 ssl_certificate_key localhost.key;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 ssl_certificate localhost.crt;
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
65 http2_max_field_size 128k;
698
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
66 http2_max_header_size 128k;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 location / {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 add_header X-Header X-Foo;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 add_header X-Sent-Foo $http_x_foo;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 add_header X-Referer $http_referer;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 return 200 'body';
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 /t {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 location /t3.html {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 limit_conn conn 1;
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 /gzip.html {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 gzip on;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 gzip_min_length 0;
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 }
680
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
84 location /frame_size {
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
85 http2_chunk_size 64k;
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
86 alias %%TESTDIR%%/t1.html;
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
87 output_buffers 2 1m;
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
88 }
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
89 location /continuation {
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
90 add_header X-LongHeader $arg_h;
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
91 add_header X-LongHeader $arg_h;
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
92 add_header X-LongHeader $arg_h;
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
93 return 200 body;
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
94
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
95 location /continuation/204 {
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
96 return 204;
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
97 }
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
98 }
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 location /pp {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 set_real_ip_from 127.0.0.1/32;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 real_ip_header proxy_protocol;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 alias %%TESTDIR%%/t2.html;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 add_header X-PP $remote_addr;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 }
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
105 location /h2 {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
106 return 200 $http2;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
107 }
716
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
108 location /sp {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
109 return 200 $server_protocol;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
110 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
111 location /scheme {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
112 return 200 $scheme;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
113 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
114 location /https {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
115 return 200 $https;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
116 }
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
117 location /chunk_size {
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
118 http2_chunk_size 1;
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
119 return 200 'body';
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
120 }
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 location /redirect {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 error_page 405 /;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 return 405;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 location /return301 {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 return 301;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 location /return301_absolute {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 return 301 text;
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 /return301_relative {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 return 301 /;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 location /proxy/ {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 add_header X-UC-a $upstream_cookie_a;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 add_header X-UC-c $upstream_cookie_c;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 proxy_pass http://127.0.0.1:8083/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 proxy_cache_valid 1m;
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
140 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
141 proxy_set_header X-Cookie-c $cookie_c;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 location /proxy2/ {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 add_header X-Body "$request_body";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 proxy_pass http://127.0.0.1:8081/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 proxy_cache_valid 1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 location /proxy_buffering_off {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 proxy_pass http://127.0.0.1:8081/;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 proxy_cache NAME;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 proxy_cache_valid 1m;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 proxy_buffering off;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 location /set-cookie {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 add_header Set-Cookie a=b;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 add_header Set-Cookie c=d;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 return 200;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 location /cookie {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 add_header X-Cookie $http_cookie;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 add_header X-Cookie-a $cookie_a;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 add_header X-Cookie-c $cookie_c;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 return 200;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 listen 127.0.0.1:8085 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170 server_name localhost;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171 return 200 first;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 server {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 listen 127.0.0.1:8085 http2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 server_name localhost2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 return 200 second;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178 }
654
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
179
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
180 server {
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
181 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
182 server_name localhost;
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
183
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
184 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
185 }
684
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
186
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
187 server {
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
188 listen 127.0.0.1:8087 http2;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
189 server_name localhost;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
190
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
191 http2_max_field_size 32;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
192 }
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
193
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
194 server {
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
195 listen 127.0.0.1:8088 http2;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
196 server_name localhost;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
197
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
198 http2_max_header_size 64;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
199 }
714
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
200
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
201 server {
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
202 listen 127.0.0.1:8089 http2;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
203 server_name localhost;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
204
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
205 http2_recv_timeout 1s;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
206 }
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
207
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
208 server {
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
209 listen 127.0.0.1:8090 http2;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
210 server_name localhost;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
211
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
212 http2_idle_timeout 1s;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
213 }
646
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
218 $t->write_file('openssl.conf', <<EOF);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
219 [ req ]
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220 default_bits = 2048
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
221 encrypt_key = no
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
222 distinguished_name = req_distinguished_name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
223 [ req_distinguished_name ]
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
224 EOF
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 my $d = $t->testdir();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
227
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
228 foreach my $name ('localhost') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
229 system('openssl req -x509 -new '
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
230 . "-config '$d/openssl.conf' -subj '/CN=$name/' "
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
231 . "-out '$d/$name.crt' -keyout '$d/$name.key' "
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
232 . ">>$d/openssl.out 2>&1") == 0
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
233 or die "Can't create certificate for $name: $!\n";
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
236 $t->run_daemon(\&http_daemon);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
237 $t->run()->waitforsocket('127.0.0.1:8083');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
238
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
239 # 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
240
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
241 $t->write_file('t1.html',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
242 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202)));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
243 $t->write_file('tbig.html',
723
bc4d6e2bd031 Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents: 722
diff changeset
244 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000)));
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 $t->write_file('t2.html', 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
247 $t->write_file('t3.html', 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
248
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
249 my %cframe = (
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
250 0 => { name => 'DATA', value => \&data },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
251 1 => { name => 'HEADERS', value => \&headers },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
252 # 2 => { name => 'PRIORITY', value => \&priority },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
253 3 => { name => 'RST_STREAM', value => \&rst_stream },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
254 4 => { name => 'SETTINGS', value => \&settings },
720
3c09ccf97d80 Tests: typo.
Sergey Kandaurov <pluknet@nginx.com>
parents: 719
diff changeset
255 # 5 => { name => 'PUSH_PROMISE', value => \&push_promise },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
256 6 => { name => 'PING', value => \&ping },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
257 7 => { name => 'GOAWAY', value => \&goaway },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
258 8 => { name => 'WINDOW_UPDATE', value => \&window_update },
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
259 9 => { name => 'CONTINUATION', value => \&headers },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
260 );
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 ###############################################################################
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 # SETTINGS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
265
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
266 my $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
267 my $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
268 { type => 'WINDOW_UPDATE' },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
269 { type => 'SETTINGS'}
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
270 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
271
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
272 my ($frame) = grep { $_->{type} eq 'WINDOW_UPDATE' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
273 ok($frame, 'WINDOW_UPDATE frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
274 is($frame->{flags}, 0, 'WINDOW_UPDATE zero flags');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
275 is($frame->{sid}, 0, 'WINDOW_UPDATE zero sid');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
276 is($frame->{length}, 4, 'WINDOW_UPDATE fixed length');
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 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
279 ok($frame, 'SETTINGS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
280 is($frame->{flags}, 0, 'SETTINGS flags');
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
281 is($frame->{sid}, 0, 'SETTINGS stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
282
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
283 h2_settings($sess, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
284 h2_settings($sess, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
285
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
286 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
287
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
288 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
289 ok($frame, 'SETTINGS frame ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
290 is($frame->{flags}, 1, 'SETTINGS flags ack');
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 # PING
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 h2_ping($sess, 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
295 $frames = h2_read($sess, all => [{ type => 'PING' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
296
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
297 ($frame) = grep { $_->{type} eq "PING" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
298 ok($frame, 'PING frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
299 is($frame->{value}, 'SEE-THIS', 'PING payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
300 is($frame->{flags}, 1, 'PING flags ack');
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
301 is($frame->{sid}, 0, 'PING stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
302
714
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
303 # timeouts
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
304
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
305 push my @sess, new_session(8089);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
306 push @sess, new_session(8089);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
307 h2_ping($sess[-1], 'SEE-THIS');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
308 push @sess, new_session(8090);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
309 push @sess, new_session(8090);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
310 h2_ping($sess[-1], 'SEE-THIS');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
311
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
312 select undef, undef, undef, 2.1;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
313
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
314 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
315 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
316 ok($frame, 'recv timeout - new connection GOAWAY');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
317 is($frame->{code}, 1, 'recv timeout - new connection code');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
318
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
319 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
320 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
321 is($frame, undef, 'recv timeout - idle connection GOAWAY');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
322
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
323 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
324 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
325 is($frame, undef, 'idle timeout - new connection GOAWAY');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
326
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
327 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
328 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
329 ok($frame, 'idle timeout - idle connection GOAWAY');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
330 is($frame->{code}, 0, 'idle timeout - idle connection code');
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
331
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332 # GET
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
333
714
ccc9f389e1f8 Tests: HTTP/2 connection timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 712
diff changeset
334 $sess = new_session();
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
335 my $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
336 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
337
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
338 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
339 ok($frame, 'HEADERS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
340 is($frame->{sid}, $sid, 'HEADERS stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
341 is($frame->{headers}->{':status'}, 200, 'HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
342 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
343
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
344 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
345 ok($frame, 'DATA frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
346 is($frame->{length}, length 'body', 'DATA length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
347 is($frame->{data}, 'body', 'DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
348
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
349 # GET in the new stream on same connection
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
350
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
351 $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
352 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
353
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
354 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
355 is($frame->{sid}, $sid, 'HEADERS stream 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
356 is($frame->{headers}->{':status'}, 200, 'HEADERS status 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
357 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEADERS header 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
358
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
359 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
360 ok($frame, 'DATA frame 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
361 is($frame->{sid}, $sid, 'HEADERS stream 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
362 is($frame->{length}, length 'body', 'DATA length 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
363 is($frame->{data}, 'body', 'DATA payload 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
364
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
365 # various HEADERS compression/encoding, see hpack() for mode details
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 # 6.1. Indexed Header Field Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
368
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
369 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
370 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
371 { 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
372 { 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
373 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
374 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
375
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
376 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
377 is($frame->{headers}->{':status'}, 200, 'indexed header field');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
378
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
379 # 6.2.1. Literal Header Field with Incremental Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
380
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
381 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
382 { name => ':method', value => 'GET', mode => 1, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
383 { 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
384 { 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
385 { name => ':authority', value => 'localhost', mode => 1, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
386 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
387
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
388 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
389 is($frame->{headers}->{':status'}, 200, 'literal with indexing');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
390
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
391 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
392 { name => ':method', value => 'GET', mode => 1, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
393 { 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
394 { 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
395 { name => ':authority', value => 'localhost', mode => 1, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
396 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
397
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
398 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
399 is($frame->{headers}->{':status'}, 200, 'literal with indexing - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
400
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
401 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
402
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
403 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
404 { name => ':method', value => 'GET', mode => 2, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
405 { 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
406 { 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
407 { name => ':authority', value => 'localhost', mode => 2, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
408 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
409
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
410 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
411 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
412
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
413 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
414 { name => ':method', value => 'GET', mode => 2, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
415 { 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
416 { 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
417 { name => ':authority', value => 'localhost', mode => 2, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
418 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
419
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
420 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
421 is($frame->{headers}->{':status'}, 200, 'literal with indexing - new huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
422
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
423 # 6.2.2. Literal Header Field without Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
424
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
425 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
426 { name => ':method', value => 'GET', mode => 3, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
427 { 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
428 { 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
429 { name => ':authority', value => 'localhost', mode => 3, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
430 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
431
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
432 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
433 is($frame->{headers}->{':status'}, 200, 'literal without indexing');
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 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
436 { name => ':method', value => 'GET', mode => 3, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
437 { 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
438 { 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
439 { name => ':authority', value => 'localhost', mode => 3, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
440 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
441
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
442 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
443 is($frame->{headers}->{':status'}, 200, 'literal without indexing - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
444
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
445 # 6.2.2. Literal Header Field without Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
446
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
447 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
448 { name => ':method', value => 'GET', mode => 4, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
449 { 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
450 { 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
451 { name => ':authority', value => 'localhost', mode => 4, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
452 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
453
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
454 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
455 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new');
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 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
458 { name => ':method', value => 'GET', mode => 4, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
459 { 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
460 { 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
461 { name => ':authority', value => 'localhost', mode => 4, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
462 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
463
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
464 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
465 is($frame->{headers}->{':status'}, 200, 'literal without indexing - new huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
466
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
467 # 6.2.3. Literal Header Field Never Indexed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
468
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
469 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
470 { name => ':method', value => 'GET', mode => 5, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
471 { 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
472 { 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
473 { name => ':authority', value => 'localhost', mode => 5, huff => 0 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
474 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
475
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
476 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
477 is($frame->{headers}->{':status'}, 200, 'literal never indexed');
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, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
480 { name => ':method', value => 'GET', mode => 5, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
481 { 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
482 { 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
483 { name => ':authority', value => 'localhost', mode => 5, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
484 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
485
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
486 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
487 is($frame->{headers}->{':status'}, 200, 'literal never indexed - huffman');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
488
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
489 # 6.2.2. Literal Header Field Never Indexed -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
490
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
491 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
492 { name => ':method', value => 'GET', mode => 6, huff => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
493 { 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
494 { 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
495 { name => ':authority', value => 'localhost', mode => 6, huff => 0 }]});
646
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;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
499 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new');
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 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
502 { name => ':method', value => 'GET', mode => 6, huff => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
503 { 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
504 { 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
505 { name => ':authority', value => 'localhost', mode => 6, huff => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
506 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
509 is($frame->{headers}->{':status'}, 200, 'literal never indexed - new huffman');
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 # reuse literal with indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
512
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
513 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
514 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
515 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
516 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
517 { 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
518 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
519 { name => 'referer', value => 'foo', mode => 1 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
520 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
521
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
522 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
523 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - new');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
524
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
525 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
526 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
527 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
528 { 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
529 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
530 { name => 'referer', value => 'foo', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
531 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
534 is($frame->{headers}->{'x-referer'}, 'foo', 'value with indexing - indexed');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
535
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
536 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
537 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
538 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
539 { 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
540 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
541 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
542 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
543
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
544 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
545 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
546
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
547 # reuse literal with indexing - reused name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
548
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
549 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
550 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
551 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
552 { 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
553 { name => ':authority', value => 'localhost', mode => 0 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
554 { name => 'x-foo', value => 'X-Bar', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
555 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
556
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
557 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
558 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
559
737
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
560 # reuse literal with indexing - reused name only
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
561
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
562 $sid = new_stream($sess, { headers => [
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
563 { name => ':method', value => 'GET', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
564 { name => ':scheme', value => 'http', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
565 { name => ':path', value => '/', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
566 { name => ':authority', value => 'localhost', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
567 { name => 'x-foo', value => 'X-Baz', mode => 1 }]});
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
568 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
569
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
570 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
571 is($frame->{headers}->{'x-sent-foo'}, 'X-Baz',
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
572 'name with indexing - indexed name');
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
573
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
574 # 6.3. Dynamic Table Size Update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
575
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
576 # 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
577 # by maintaining dynamic table space only for index 0
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
578 # 'x-foo' has index 0, and 'referer' has index 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
579
737
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
580 $sess = new_session();
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
581 $sid = new_stream($sess, { headers => [
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
582 { name => ':method', value => 'GET', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
583 { name => ':scheme', value => 'http', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
584 { name => ':path', value => '/', mode => 0 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
585 { name => ':authority', value => 'localhost', mode => 1 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
586 { name => 'referer', value => 'foo', mode => 1 },
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
587 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
588 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
abf42eb6cf48 Tests: HTTP/2 test for indexed header field name in dynamic table.
Sergey Kandaurov <pluknet@nginx.com>
parents: 736
diff changeset
589
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
590 $sid = new_stream($sess, { table_size => 61, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
591 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
592 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
593 { 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
594 { 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
595 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
596 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
597
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
598 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
599 isnt($frame, undef, 'updated table size - remaining index');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
600
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
601 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
602 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
603 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
604 { 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
605 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
606 { name => 'referer', value => 'foo', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
607 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
608
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
609 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
610 is($frame, undef, 'invalid index');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
611
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
612 # 5.4.1. Connection Error Handling
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
613 # An endpoint that encounters a connection error SHOULD first send a
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
614 # GOAWAY frame <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
615
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
616 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
617 ok($frame, 'invalid index - GOAWAY');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
618
691
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
619 # RFC 7541, 2.3.3. Index Address Space
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
620 # Indices strictly greater than the sum of the lengths of both tables
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
621 # MUST be treated as a decoding error.
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
622
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
623 # 4.3. Header Compression and Decompression
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
624 # A decoding error in a header block MUST be treated
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
625 # as a connection error of type COMPRESSION_ERROR.
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
626
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
627 is($frame->{last_sid}, $sid, 'invalid index - GOAWAY last stream');
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
628 is($frame->{code}, 9, 'invalid index - GOAWAY COMPRESSION_ERROR');
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
629
729
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
630 # invalid table size update
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
631
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
632 $sess = new_session();
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
633 $sid = new_stream($sess, { table_size => 4097, headers => [
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
634 { name => ':method', value => 'GET', mode => 0 },
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
635 { name => ':scheme', value => 'http', mode => 0 },
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
636 { name => ':path', value => '/', mode => 0 },
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
637 { name => 'x-foo', value => 'X-Bar', mode => 0 },
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
638 { name => ':authority', value => 'localhost', mode => 1 }]});
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
639 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
640
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
641 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
642 ok($frame, 'invalid table size - GOAWAY');
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
643 is($frame->{last_sid}, $sid, 'invalid table size - GOAWAY last stream');
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
644 is($frame->{code}, 9, 'invalid table size - GOAWAY COMPRESSION_ERROR');
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
645
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
646 # HEAD
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
647
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
648 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
649 $sid = new_stream($sess, { method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
650 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
651
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
652 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
653 is($frame->{sid}, $sid, 'HEAD - HEADERS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
654 is($frame->{headers}->{':status'}, 200, 'HEAD - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
655 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEAD - HEADERS header');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
656
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
657 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
658 is($frame, undef, 'HEAD - no body');
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 # GET with PROXY protocol
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
661
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
662 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
663 $sess = new_session(8082, proxy => $proxy);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
664 $sid = new_stream($sess, { path => '/pp' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
665 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
666
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
667 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
668 ok($frame, 'PROXY HEADERS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
669 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
670
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
671 # range filter
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
672
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
673 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
674 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
675 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
676 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
677 { 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
678 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
679 { name => 'range', value => 'bytes=10-19', mode => 1 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
680 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
681
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
682 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
683 is($frame->{headers}->{':status'}, 206, 'range - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
684
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
685 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
686 is($frame->{length}, 10, 'range - DATA length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
687 is($frame->{data}, '002XXXX000', 'range - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
688
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
689 # $http2
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
690
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
691 $sess = new_session();
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
692 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
693 $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
694
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
695 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
696 is($frame->{data}, 'h2c', 'http variable - h2c');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
697
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
698 # SSL/TLS connection, NPN
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
699
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
700 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
701 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
702 skip 'OpenSSL NPN support required', 1 if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
703
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
704 $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
705 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
706 $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
707
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
708 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
709 is($frame->{data}, 'h2', 'http variable - npn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
710
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
711 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
712
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
713 # SSL/TLS connection, ALPN
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
714
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
715 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
716 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
717 skip 'OpenSSL ALPN support required', 1 if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
718
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
719 $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
720 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
721 $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
722
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
723 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
724 is($frame->{data}, 'h2', 'http variable - alpn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
725
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
726 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
727
716
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
728 # $server_protocol
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
729
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
730 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
731 $sid = new_stream($sess, { path => '/sp' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
732 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
733
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
734 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
735 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
736
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
737 # $server_protocol - SSL/TLS connection, NPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
738
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
739 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
740 eval { IO::Socket::SSL->can_npn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
741 skip 'OpenSSL NPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
742
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
743 $sess = new_session(8084, SSL => 1, npn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
744 $sid = new_stream($sess, { path => '/sp' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
745 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
746
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
747 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
748 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - npn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
749
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
750 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
751
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
752 # $server_protocol - SSL/TLS connection, ALPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
753
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
754 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
755 eval { IO::Socket::SSL->can_alpn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
756 skip 'OpenSSL ALPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
757
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
758 $sess = new_session(8084, SSL => 1, alpn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
759 $sid = new_stream($sess, { path => '/sp' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
760 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
761
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
762 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
763 is($frame->{data}, 'HTTP/2.0', 'server_protocol variable - alpn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
764
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
765 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
766
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
767 # $scheme
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
768
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
769 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
770 $sid = new_stream($sess, { path => '/scheme' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
771 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
772
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
773 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
774 is($frame->{data}, 'http', 'scheme variable');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
775
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
776 # $scheme - SSL/TLS connection, NPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
777
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
778 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
779 eval { IO::Socket::SSL->can_npn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
780 skip 'OpenSSL NPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
781
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
782 $sess = new_session(8084, SSL => 1, npn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
783 $sid = new_stream($sess, { path => '/scheme' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
784 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
785
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
786 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
787 is($frame->{data}, 'https', 'scheme variable - npn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
788
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
789 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
790
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
791 # $scheme - SSL/TLS connection, ALPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
792
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
793 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
794 eval { IO::Socket::SSL->can_alpn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
795 skip 'OpenSSL ALPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
796
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
797 $sess = new_session(8084, SSL => 1, alpn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
798 $sid = new_stream($sess, { path => '/scheme' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
799 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
800
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
801 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
802 is($frame->{data}, 'https', 'scheme variable - alpn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
803
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
804 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
805
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
806 # $https
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
807
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
808 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
809 $sid = new_stream($sess, { path => '/https' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
810 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
811
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
812 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
813 is($frame->{data}, '', 'https variable');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
814
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
815 # $https - SSL/TLS connection, NPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
816
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
817 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
818 eval { IO::Socket::SSL->can_npn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
819 skip 'OpenSSL NPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
820
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
821 $sess = new_session(8084, SSL => 1, npn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
822 $sid = new_stream($sess, { path => '/https' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
823 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
824
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
825 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
826 is($frame->{data}, 'on', 'https variable - npn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
827
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
828 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
829
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
830 # $https - SSL/TLS connection, ALPN
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
831
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
832 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
833 eval { IO::Socket::SSL->can_alpn() or die; };
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
834 skip 'OpenSSL ALPN support required', 1 if $@;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
835
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
836 $sess = new_session(8084, SSL => 1, alpn => 'h2');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
837 $sid = new_stream($sess, { path => '/https' });
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
838 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
839
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
840 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
841 is($frame->{data}, 'on', 'https variable - alpn');
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
842
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
843 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
844
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
845 # http2_chunk_size=1
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
846
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
847 $sess = new_session();
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
848 $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
849 $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
850
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
851 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
852 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
853 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
854 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
855
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
856 # CONTINUATION
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
857
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
858 $sess = new_session();
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
859 $sid = new_stream($sess, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
860 { name => ':method', value => 'HEAD', mode => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
861 { 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
862 { 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
863 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
864 h2_continue($sess, $sid, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
865 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
866 h2_continue($sess, $sid, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
867 { name => 'referer', value => 'foo', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
868 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
869
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
870 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
871 is($frame, undef, 'CONTINUATION - fragment 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
872
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
873 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
874 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
875 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
876
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
877 # CONTINUATION - in the middle of request header field
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
878
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
879 $sess = new_session();
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
880 $sid = new_stream($sess, { continuation => [ 2, 4, 1, 5 ], headers => [
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
881 { name => ':method', value => 'HEAD', mode => 1 },
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
882 { name => ':scheme', value => 'http', mode => 0 },
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
883 { name => ':path', value => '/', mode => 0 },
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
884 { name => ':authority', value => 'localhost', mode => 1 }]});
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
885 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
886
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
887 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
888 is($frame->{headers}->{':status'}, 200, 'CONTINUATION - in header field');
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
889
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
890 # frame padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
891
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
892 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
893 $sid = new_stream($sess, { padding => 42, 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 },
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
896 { 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
897 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
898 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
899
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
900 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
901 is($frame->{headers}->{':status'}, 200, 'padding - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
902
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
903 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
904 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
905 { 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
906 { 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
907 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
908 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
909
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
910 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
911 is($frame->{headers}->{':status'}, 200, 'padding - next stream');
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 # request header field with multiple values
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 # 8.1.2.5. Compressing the Cookie Header Field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
916 # To allow for better compression efficiency, the Cookie header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
917 # MAY be split into separate header fields <..>.
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
920 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
921 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
922 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
923 { 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
924 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
925 { name => 'cookie', value => 'a=b', mode => 2},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
926 { name => 'cookie', value => 'c=d', mode => 2}]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
927 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
928
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
929 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
930 is($frame->{headers}->{'x-cookie-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
931 'multiple request header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
932 is($frame->{headers}->{'x-cookie-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
933 'multiple request header fields - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
934 is($frame->{headers}->{'x-cookie'}, 'a=b; c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
935 'multiple request header fields - semi-colon');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
936
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
937 # request header field with multiple values to HTTP backend
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
938
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
939 # 8.1.2.5. Compressing the Cookie Header Field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
940 # these MUST be concatenated into a single octet string
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
941 # using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
942 # 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
943 # connection <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
944
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
945 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
946 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
947 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
948 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
949 { 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
950 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
951 { name => 'cookie', value => 'a=b', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
952 { name => 'cookie', value => 'c=d', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
953 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
954
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
955 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
956 is($frame->{headers}->{'x-sent-cookie'}, 'a=b; c=d',
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
957 '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
958 is($frame->{headers}->{'x-sent-cookie2'}, '',
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
959 'multiple request header fields proxied - dublicate cookie');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
960 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
961 'multiple request header fields proxied - cookie 1');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
962 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
963 'multiple request header fields proxied - cookie 2');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
964
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
965 # response header field with multiple values
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
968 $sid = new_stream($sess, { path => '/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
969 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
970
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
971 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
972 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
973 'multiple response header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
974 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
975 'multiple response header fields - cookie 2');
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 # response header field with multiple values from HTTP backend
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
978
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
979 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
980 $sid = new_stream($sess, { path => '/proxy/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
981 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
984 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
985 'multiple response header proxied - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
986 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
987 'multiple response header proxied - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
988 is($frame->{headers}->{'x-uc-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
989 'multiple response header proxied - upstream cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
990 is($frame->{headers}->{'x-uc-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
991 'multiple response header proxied - upstream cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
992
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
993 # internal redirect
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 $sid = new_stream($sess, { path => '/redirect' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
997 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1000 is($frame->{headers}->{':status'}, 405, 'redirect - HEADERS');
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 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1003 ok($frame, 'redirect - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1004 is($frame->{data}, 'body', 'redirect - DATA payload');
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 # return 301 with absolute URI
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1009 $sid = new_stream($sess, { path => '/return301_absolute' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1010 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1011
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1012 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1013 is($frame->{headers}->{':status'}, 301, 'return 301 absolute - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1014 is($frame->{headers}->{'location'}, 'text', 'return 301 absolute - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1015
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1016 # return 301 with relative URI
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1017
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1018 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1019 $sid = new_stream($sess, { path => '/return301_relative' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1020 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1021
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1022 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1023 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1024 is($frame->{headers}->{'location'}, 'http://127.0.0.1:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1025 'return 301 relative - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1026
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1027 # return 301 with relative URI and ':authority' request header field
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1030 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1031 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1032 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1033 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1034 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1035 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1036
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1037 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1038 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1039 'return 301 relative - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1040 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1041 'return 301 relative - authority - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1042
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1043 # return 301 with relative URI and 'host' request header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1044
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1045 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1046 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1047 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1048 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1049 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1050 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1051 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1052
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1053 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1054 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1055 'return 301 relative - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1056 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1057 'return 301 relative - host - location');
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 # virtual host
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1060
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1061 $sess = new_session(8085);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1062 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1063 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1064 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1065 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1066 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1067 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1068
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1069 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1070 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1071 'virtual host - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1072
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1073 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1074 is($frame->{data}, 'first', 'virtual host - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1075
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1076 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1077 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1078 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1079 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1080 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1081 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1082
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1083 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1084 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1085 'virtual host - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1086
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1087 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1088 is($frame->{data}, 'first', 'virtual host - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1089
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1090 # virtual host - second
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1091
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1092 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1093 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1094 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1095 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1096 { name => 'host', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1097 $frames = h2_read($sess, all => [{ sid => $sid, 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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1100 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1101 'virtual host 2 - host - status');
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 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1104 is($frame->{data}, 'second', 'virtual host 2 - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1105
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1106 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1107 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1108 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1109 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1110 { name => ':authority', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1111 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1112
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1113 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1114 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1115 'virtual host 2 - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1116
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1117 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1118 is($frame->{data}, 'second', 'virtual host 2 - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1119
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1120 # gzip tests for internal nginx version
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1121
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1122 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1123 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1124 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1125 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1126 { 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
1127 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1128 { name => 'accept-encoding', value => 'gzip' }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1129 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1130
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1131 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1132 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1133
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1134 ($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
1135 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1136
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1137 # simple proxy cache test
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1138
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1139 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1140 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1141 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1142
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1143 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1144 is($frame->{headers}->{':status'}, '200', 'proxy cache');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1145
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1146 my $etag = $frame->{headers}->{'etag'};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1147
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1148 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1149 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1150 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1151
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1152 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1153 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1154 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1155 { 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
1156 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1157 { name => 'if-none-match', value => $etag }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1158 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1159
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1160 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1161 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1162
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1163 # HEADERS could be received with fin, followed by DATA
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1164
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1165 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1166 $sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1167
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1168 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1169 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1170 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1171
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1172 # HEAD on empty cache with proxy_buffering off
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1173
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1174 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1175 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1176 { path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1177
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1178 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1179 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1180 ok(!grep ({ $_->{type} eq "DATA" } @$frames),
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1181 'proxy cache HEAD buffering off - no body');
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 # request body (uses proxied response)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1184
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1185 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1186 $sid = new_stream($sess, { path => '/proxy2/t2.html', body => 'TEST' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1187 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1188
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1189 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1190 is($frame->{headers}->{'x-body'}, 'TEST', 'request body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1191
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1192 # request body with padding (uses proxied response)
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1195 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1196 { path => '/proxy2/t2.html', body => 'TEST', body_padding => 42 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1197 $frames = h2_read($sess, all => [{ sid => $sid, fin => 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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1200 is($frame->{headers}->{'x-body'}, 'TEST', 'request body with padding');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1201
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1202 $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1203 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1204
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1205 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1206 is($frame->{headers}->{':status'}, '200', 'request body with padding - next');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1207
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1208 # initial window size, client side
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1209
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1210 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1211 # When an HTTP/2 connection is first established, new streams are
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1212 # 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
1213 # The connection flow-control window is also 65,535 octets.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1214
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1215 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1216 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1217 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1218
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1219 # 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
1220
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
1221 @data = grep { $_->{type} eq "DATA" } @$frames;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1222 my $lengths = join ' ', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1223 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1224 'iws - stream blocked on initial window size');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1225
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1226 h2_ping($sess, 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1227 $frames = h2_read($sess, all => [{ type => 'PING' }]);
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 ($frame) = grep { $_->{type} eq "PING" && $_->{flags} & 0x1 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1230 ok($frame, 'iws - PING not blocked');
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 h2_window($sess, 2**16, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1233 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1234 is(@$frames, 0, 'iws - updated stream window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1235
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1236 h2_window($sess, 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1237 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1238
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1239 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1240 my $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1241 is($sum, 81, 'iws - updated connection window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1242
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1243 # SETTINGS (initial window size, client side)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1244
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1245 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1246 # 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
1247 # including a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1248 # frame that forms part of the connection preface. The connection
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1249 # flow-control window can only be changed using WINDOW_UPDATE frames.
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1252 h2_settings($sess, 0, 0x4 => 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1253 h2_window($sess, 2**17);
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 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1256 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1259 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1260 is($sum, 2**16 + 80, 'iws - increased');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1261
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1262 # probe for negative available space in a flow control window
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 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1265 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1266 # 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
1267 # 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
1268 # controlled frames until it receives WINDOW_UPDATE frames that cause
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1269 # the flow-control window to become positive.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1270
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1271 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1272 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1273 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1274
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1275 h2_window($sess, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1276 h2_settings($sess, 0, 0x4 => 42);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1277 h2_window($sess, 1024, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1278
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1279 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1280
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1281 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1282 ok($frame, 'negative window - SETTINGS frame ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1283 is($frame->{flags}, 1, 'negative window - SETTINGS flags ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1284
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1285 ($frame) = grep { $_->{type} ne 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1286 is($frame, undef, 'negative window - no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1287
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1288 # predefined window size, minus new iws settings, minus window update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1289
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1290 h2_window($sess, 2**16 - 1 - 42 - 1024, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1291
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1292 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1293 is(@$frames, 0, 'zero window - no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1294
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1295 h2_window($sess, 1, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1296
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1297 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1298 is(@$frames, 1, 'positive window');
712
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1299
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1300 SKIP: {
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1301 skip 'failed connection', 2 unless @$frames;
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1302
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1303 is(@$frames[0]->{type}, 'DATA', 'positive window - data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1304 is(@$frames[0]->{length}, 1, 'positive window - data length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1305
712
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1306 }
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1307
704
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1308 # ask write handler in sending large response
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1309
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1310 $sid = new_stream($sess, { path => '/tbig.html' });
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1311
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1312 h2_window($sess, 2**30, $sid);
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1313 h2_window($sess, 2**30);
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1314
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1315 sleep 1;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1316 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1317
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1318 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1319 is($frame->{headers}->{':status'}, 200, 'large response - HEADERS');
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1320
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1321 @data = grep { $_->{type} eq "DATA" } @$frames;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1322 $sum = eval join '+', map { $_->{length} } @data;
723
bc4d6e2bd031 Tests: adjusted HTTP/2 test to trigger write handler in v2 module.
Sergey Kandaurov <pluknet@nginx.com>
parents: 722
diff changeset
1323 is($sum, 5000000, 'large response - DATA');
704
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1324
680
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1325 # SETTINGS_MAX_FRAME_SIZE
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1326
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1327 $sess = new_session();
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1328 $sid = new_stream($sess, { path => '/frame_size' });
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1329 h2_window($sess, 2**18, 1);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1330 h2_window($sess, 2**18);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1331
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1332 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1333 @data = grep { $_->{type} eq "DATA" } @$frames;
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1334 is($data[0]->{length}, 2**14, 'max frame size - default');
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1335
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1336 $sess = new_session();
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1337 h2_settings($sess, 0, 0x5 => 2**15);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1338 $sid = new_stream($sess, { path => '/frame_size' });
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1339 h2_window($sess, 2**18, 1);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1340 h2_window($sess, 2**18);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1341
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1342 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1343 @data = grep { $_->{type} eq "DATA" } @$frames;
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1344 is($data[0]->{length}, 2**15, 'max frame size - custom');
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1345
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1346 # CONTINUATION in response
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1347 # put three long header fields (not less than SETTINGS_MAX_FRAME_SIZE/2)
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1348 # to break header block into separate frames, one such field per frame
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1349
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1350 $sess = new_session();
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1351 $sid = new_stream($sess, { path => '/continuation?h=' . 'x' x 2**13 });
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1352
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1353 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1354 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1355 is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1356 'response CONTINUATION - headers');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1357 is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1358 'response CONTINUATION - header 1');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1359 is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1360 'response CONTINUATION - header 2');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1361 is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1362 'response CONTINUATION - header 3');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1363 @data = sort { $a <=> $b } map { $_->{length} } @data;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1364 cmp_ok($data[-1], '<=', 2**14, 'response CONTINUATION - max frame size');
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1365
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1366 # same but without response DATA frames
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1367
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1368 $sess = new_session();
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1369 $sid = new_stream($sess, { path => '/continuation/204?h=' . 'x' x 2**13 });
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1370
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1371 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1372 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1373 is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1374 'no body CONTINUATION - headers');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1375 is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1376 'no body CONTINUATION - header 1');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1377 is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1378 'no body CONTINUATION - header 2');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1379 is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1380 'no body CONTINUATION - header 3');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1381 @data = sort { $a <=> $b } map { $_->{length} } @data;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1382 cmp_ok($data[-1], '<=', 2**14, 'no body CONTINUATION - max frame size');
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1383
698
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1384 # response header block is always split by SETTINGS_MAX_FRAME_SIZE
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1385
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1386 TODO: {
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1387 local $TODO = 'not yet';
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1388
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1389 $sess = new_session();
719
91bedf9d60a7 Tests: adjusted field length in HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 718
diff changeset
1390 $sid = new_stream($sess, { path => '/continuation?h=' . 'x' x 2**15 });
698
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1391
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1392 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1393 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1394 @data = sort { $a <=> $b } map { $_->{length} } @data;
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1395 cmp_ok($data[-1], '<=', 2**14, 'response header frames limited');
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1396
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1397 }
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1398
684
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1399 # max_field_size
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1400
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1401 $sess = new_session(8087);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1402 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1403 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1404 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1405 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1406 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1407 { name => 'longname10', value => 'valu5' x 4 . 'x', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1408 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1409
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1410 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1411 ok($frame, 'field size less');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1412
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1413 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1414 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1415 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1416 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1417 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1418 { name => 'longname10', value => 'valu5' x 4 . 'x', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1419 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1420
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1421 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1422 ok($frame, 'field size second');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1423
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1424 $sess = new_session(8087);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1425 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1426 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1427 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1428 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1429 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1430 { name => 'longname10', value => 'valu5' x 4 . 'xx', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1431 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1432
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1433 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1434 ok($frame, 'field size equal');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1435
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1436 $sess = new_session(8087);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1437 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1438 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1439 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1440 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1441 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1442 { name => 'longname10', value => 'valu5' x 4 . 'xxx', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1443 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1444
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1445 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1446 is($frame, undef, 'field size greater');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1447
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1448 # max_header_size
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1449
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1450 $sess = new_session(8088);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1451 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1452 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1453 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1454 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1455 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1456 { name => 'longname9', value => 'x', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1457 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1458
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1459 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1460 ok($frame, 'header size less');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1461
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1462 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1463 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1464 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1465 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1466 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1467 { name => 'longname9', value => 'x', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1468 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1469
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1470 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1471 ok($frame, 'header size second');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1472
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1473 $sess = new_session(8088);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1474 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1475 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1476 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1477 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1478 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1479 { name => 'longname9', value => 'xx', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1480 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1481
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1482 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1483 ok($frame, 'header size equal');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1484
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1485 $sess = new_session(8088);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1486 $sid = new_stream($sess, { headers => [
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1487 { name => ':method', value => 'GET', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1488 { name => ':scheme', value => 'http', mode => 0 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1489 { name => ':path', value => '/t2.html', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1490 { name => ':authority', value => 'localhost', mode => 1 },
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1491 { name => 'longname9', value => 'xxx', mode => 2 }]});
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1492 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1493
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1494 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1495 is($frame, undef, 'header size greater');
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1496
722
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1497 # header size is based on (decompressed) header list
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1498 # two extra 1-byte indices would otherwise fit in max_header_size
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1499
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1500 $sess = new_session(8088);
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1501 $sid = new_stream($sess, { headers => [
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1502 { name => ':method', value => 'GET', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1503 { name => ':scheme', value => 'http', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1504 { name => ':path', value => '/t2.html', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1505 { name => ':authority', value => 'localhost', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1506 { name => 'longname9', value => 'x', mode => 2 }]});
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1507 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1508
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1509 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1510 ok($frame, 'header size new index');
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1511
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1512 $sid = new_stream($sess, { headers => [
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1513 { name => ':method', value => 'GET', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1514 { name => ':scheme', value => 'http', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1515 { name => ':path', value => '/t2.html', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1516 { name => ':authority', value => 'localhost', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1517 { name => 'longname9', value => 'x', mode => 0 }]});
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1518 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1519
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1520 ($frame) = grep { $_->{type} eq 'DATA' } @$frames;
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1521 ok($frame, 'header size indexed');
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1522
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1523 $sid = new_stream($sess, { headers => [
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1524 { name => ':method', value => 'GET', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1525 { name => ':scheme', value => 'http', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1526 { name => ':path', value => '/t2.html', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1527 { name => ':authority', value => 'localhost', mode => 1 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1528 { name => 'longname9', value => 'x', mode => 0 },
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1529 { name => 'longname9', value => 'x', mode => 0 }]});
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1530 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1531
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1532 ($frame) = grep { $_->{type} eq 'GOAWAY' } @$frames;
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1533 is($frame->{code}, 0xb, 'header size indexed greater');
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1534
736
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1535 # HPACK table boundary
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1536
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1537 $sess = new_session();
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1538 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1539 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1540 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1541 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1542 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1543 { name => 'x' x 2016, value => 'x' x 2048, mode => 2 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1544 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1545 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1546 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1547 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1548 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1549 { name => 'x' x 2016, value => 'x' x 2048, mode => 0 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1550
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1551 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1552 ok($frame, 'HPACK table boundary');
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1553
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1554 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1555 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1556 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1557 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1558 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1559 { name => 'x' x 33, value => 'x' x 4031, mode => 2 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1560 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1561 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1562 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1563 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1564 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1565 { name => 'x' x 33, value => 'x' x 4031, mode => 0 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1566
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1567 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1568 ok($frame, 'HPACK table boundary - header field name');
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1569
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1570 h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1571 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1572 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1573 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1574 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1575 { name => 'x', value => 'x' x 64, mode => 2 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1576 $frames = h2_read($sess, all => [{ sid => new_stream($sess, { headers => [
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1577 { name => ':method', value => 'GET', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1578 { name => ':scheme', value => 'http', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1579 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1580 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1581 { name => 'x', value => 'x' x 64, mode => 0 }]}), fin => 1 }]);
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1582
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1583 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1584 ok($frame, 'HPACK table boundary - header field value');
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1585
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1586 # stream multiplexing + WINDOW_UPDATE
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1589 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1590 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1593 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1594 is($sum, 2**16 - 1, 'multiple - stream1 data');
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 my $sid2 = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1597 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1600 is(@data, 0, 'multiple - stream2 no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1601
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1602 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1603 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1604 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1605
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1606 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1607 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1608 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1609 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1610
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1611 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1612 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1613 is($sum, 81, 'multiple - stream1 remain data');
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 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1616 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1617 is($sum, 2**16 + 80, 'multiple - stream2 full data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1618
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1619 # stream muliplexing + PRIORITY frames
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1622 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1623 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1624
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1625 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1626 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1627
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1628 h2_priority($sess, 0, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1629 h2_priority($sess, 255, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1630
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1631 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1632 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1633 h2_window($sess, 2**17);
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 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1636 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1637 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1638 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1639
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1640 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1641 is(join(' ', map { $_->{sid} } @data), "$sid2 $sid", 'weight - PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1642
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1643 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1644
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1645 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1646 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1647 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1648
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1649 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1650 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1651
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1652 h2_priority($sess, 255, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1653 h2_priority($sess, 0, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1654
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1655 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1656 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1657 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1658
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1659 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1660 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1661 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1662 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1663
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1664 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1665 is(join(' ', map { $_->{sid} } @data), "$sid $sid2", 'weight - PRIORITY 2');
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 # stream muliplexing + HEADERS PRIORITY flag
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1668
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1669 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1670 $sid = new_stream($sess, { path => '/t1.html', prio => 0 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1671 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1672
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1673 $sid2 = new_stream($sess, { path => '/t2.html', prio => 255 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1674 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1675
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1676 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1677 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1678 h2_window($sess, 2**17);
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 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1681 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1682 { sid => $sid2, fin => 1 }
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1685 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1686 my $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1687 is($sids, "$sid2 $sid", 'weight - HEADERS PRIORITY 1');
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 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1690
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1691 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1692 $sid = new_stream($sess, { path => '/t1.html', prio => 255 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1693 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1694
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1695 $sid2 = new_stream($sess, { path => '/t2.html', prio => 0 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1696 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
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 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1699 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1700 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1701
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1702 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1703 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1704 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1705 ]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1708 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1709 is($sids, "$sid $sid2", 'weight - HEADERS PRIORITY 2');
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 # 5.3.1. Stream Dependencies
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1712
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1713 # PRIORITY frame
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1714
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1715 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1716
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1717 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1718 h2_priority($sess, 16, 1, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1719
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1720 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1721 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1722
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1723 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1724 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1725
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1726 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1727 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1728 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1729
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1730 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1731 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1732 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1733 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1734
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1735 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1736 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1737 is($sids, "$sid2 $sid", 'dependency - PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1738
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1739 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1740
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1741 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1742
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1743 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1744 h2_priority($sess, 16, 3, 1);
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 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1747 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
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 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1750 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1751
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1752 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1753 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1754 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1755
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1756 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1757 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1758 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1759 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1760
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1761 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1762 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1763 is($sids, "$sid $sid2", 'dependency - PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1764
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1765 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1766
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1767 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1768
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1769 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1770 h2_priority($sess, 16, 3, 0);
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 $sid = new_stream($sess, { path => '/t1.html', dep => 3 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1773 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1774
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1775 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1776 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
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 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1779 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1780 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1781
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1782 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1783 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1784 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1785 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1786
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1787 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1788 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1789 is($sids, "$sid2 $sid", 'dependency - HEADERS PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1790
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1791 # and vice versa
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1792
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1793 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1794
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1795 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1796 h2_priority($sess, 16, 3, 0);
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 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1799 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
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 $sid2 = new_stream($sess, { path => '/t2.html', dep => 1 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1802 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1803
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1804 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1805 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1806 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1807
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1808 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1809 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1810 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1811 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1812
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1813 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1814 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1815 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1816
662
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1817 # PRIORITY frame, weighted dependencies
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1818
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1819 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1820
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1821 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1822 h2_priority($sess, 255, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1823 h2_priority($sess, 0, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1824
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1825 $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
1826 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
1827
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1828 $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
1829 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
1830
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1831 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
1832 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
1833
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1834 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1835 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1836 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1837 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1838
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1839 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1840 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1841 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1842 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1843 ]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1844
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1845 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1846 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1847 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
1848
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1849 # and vice versa
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1850
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1851 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1852
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1853 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1854 h2_priority($sess, 0, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1855 h2_priority($sess, 255, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1856
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1857 $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
1858 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
1859
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1860 $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
1861 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
1862
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1863 $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
1864 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
1865
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1866 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1867 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1868 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1869 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1870
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1871 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1872 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1873 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1874 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1875 ]);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1876
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1877 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1878 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1879 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
1880
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1881 # limit_conn
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1882
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1883 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1884 h2_settings($sess, 0, 0x4 => 1);
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 $sid = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1887 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1888
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1889 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1890 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1891
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1892 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1893 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1896 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1897
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1898 h2_settings($sess, 0, 0x4 => 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1899
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1900 h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1901 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1902 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1903 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1904
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1905 # limit_conn + client's RST_STREAM
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1906
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1907 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1908 h2_settings($sess, 0, 0x4 => 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1909
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1910 $sid = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1911 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1912 h2_rst($sess, $sid, 5);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1913
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1914 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1915 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
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 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1918 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1921 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1922
654
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1923 # http2_max_concurrent_streams
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1924
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1925 $sess = new_session(8086);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1926 $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
1927
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1928 ($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
1929 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
1930
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1931 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
1932
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1933 $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
1934 $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
1935
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1936 ($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
1937 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
1938
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1939 $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
1940 $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
1941
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1942 ($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
1943 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
1944
667
0247e314e991 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 662
diff changeset
1945 ($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
1946 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
1947 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
1948 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
1949 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
1950
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1951 # properly skip header field that's not/never indexed from discarded streams
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1952
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1953 $sid2 = new_stream($sess, { headers => [
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1954 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1955 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1956 { name => ':path', value => '/', mode => 6 },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1957 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1958 { name => 'x-foo', value => 'Foo', mode => 2 }]});
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1959 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1960
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1961 # also if split across writes
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1962
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1963 $sid2 = new_stream($sess, { split => [ 22 ], headers => [
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1964 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1965 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1966 { name => ':path', value => '/', mode => 6 },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1967 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1968 { name => 'x-bar', value => 'Bar', mode => 2 }]});
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1969 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1970
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1971 # also if split across frames
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1972
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1973 $sid2 = new_stream($sess, { continuation => [ 17 ], headers => [
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1974 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1975 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1976 { name => ':path', value => '/', mode => 6 },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1977 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1978 { name => 'x-baz', value => 'Baz', mode => 2 }]});
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1979 $frames = h2_read($sess, all => [{ type => 'RST_STREAM' }]);
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1980
661
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1981 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
1982 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
1983
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1984 $sid = new_stream($sess, { headers => [
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1985 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1986 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1987 { name => ':path', value => '/t2.html' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1988 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1989 # make sure that discarded streams updated dynamic table
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1990 { name => 'x-foo', value => 'Foo', mode => 0 },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1991 { name => 'x-bar', value => 'Bar', mode => 0 },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1992 { name => 'x-baz', value => 'Baz', mode => 0 }]});
661
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1993 $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
1994
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1995 ($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
1996 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
1997
646
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 # some invalid cases below
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2000
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2001 # invalid connection preface
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2002
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2003 $sess = new_session(8080, preface => 'bogus preface');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2004 $sid = new_stream($sess, { path => '/pp' });
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2005 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2006
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2007 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2008 ok($frame, 'invalid preface - GOAWAY frame');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2009 is($frame->{code}, 1, 'invalid preface - error code');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2010
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2011 $sess = new_session(8080, preface => 'PRI * HTTP/2.0' . CRLF . CRLF . 'bogus');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2012 $sid = new_stream($sess, { path => '/pp' });
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2013 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2014
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2015 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2016 ok($frame, 'invalid preface 2 - GOAWAY frame');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2017 is($frame->{code}, 1, 'invalid preface 2 - error code');
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2018
727
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2019 # invalid PROXY protocol string
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2020
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2021 $sess = new_session(8082, proxy => 'bogus');
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2022 $sid = new_stream($sess, { path => '/pp' });
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2023 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2024
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2025 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2026 ok($frame, 'invalid PROXY - GOAWAY frame');
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2027 is($frame->{code}, 1, 'invalid PROXY - error code');
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2028
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2029 # 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
2030 #
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2031 # 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
2032 # 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
2033 # 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
2034
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2035 $sess = new_session();
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2036 $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
2037 { 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
2038 { 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
2039 { 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
2040 { 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
2041 { 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
2042 $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
2043
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2044 # 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
2045 # 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
2046 # 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
2047
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2048 ($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
2049 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
2050
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2051 # 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
2052 # 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
2053 # 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
2054
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2055 ($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
2056 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
2057 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
2058 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
2059 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
2060
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2061 # GOAWAY on SYN_STREAM with even StreamID
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2064 new_stream($sess, { path => '/' }, 2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2065 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2066
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2067 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2068 ok($frame, 'even stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2069 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
2070 is($frame->{last_sid}, 0, 'even stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2071
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2072 # GOAWAY on SYN_STREAM with backward StreamID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2073
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2074 # 5.1.1. Stream Identifiers
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2075 # 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
2076 # 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
2077
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2078 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2079 $sid = new_stream($sess, { path => '/' }, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2080 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2081
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2082 $sid2 = new_stream($sess, { path => '/' }, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2083 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2084
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2085 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2086 ok($frame, 'backward stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2087 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
2088 is($frame->{last_sid}, $sid, 'backward stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2089
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2090 # GOAWAY on the second SYN_STREAM with same StreamID
646
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2093 $sid = new_stream($sess, { path => '/' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2094 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2095
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2096 $sid2 = new_stream($sess, { path => '/' }, $sid);
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2097 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2098
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2099 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2100 ok($frame, 'dup stream - GOAWAY frame');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2101 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
2102 is($frame->{last_sid}, $sid, 'dup stream - last stream');
646
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 # missing mandatory request header ':scheme'
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2105
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2106 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2107 local $TODO = 'not yet';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2108
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2109 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2110 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2111 { 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
2112 { 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
2113 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2114 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2115
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2116 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2117 is($frame->{headers}->{':status'}, 400, 'incomplete headers');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2118
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2119 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2120
673
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2121 # empty request header ':authority'
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2122
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2123 $sess = new_session();
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2124 $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
2125 { 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
2126 { 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
2127 { 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
2128 { 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
2129 $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
2130
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2131 ($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
2132 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
2133
697
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2134 # unknown frame type
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2135
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2136 $sess = new_session();
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2137 h2_unknown($sess, 'payload');
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2138 h2_ping($sess, 'SEE-THIS');
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2139 $frames = h2_read($sess, all => [{ type => 'PING' }]);
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2140
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2141 ($frame) = grep { $_->{type} eq "PING" } @$frames;
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2142 is($frame->{value}, 'SEE-THIS', 'unknown frame type');
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2143
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2144 # GOAWAY - force closing a connection by server
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2145
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2146 $sid = new_stream($sess, { path => 't1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2147 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
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 $t->stop();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2150
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2151 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
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 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2154 ok($frame, 'GOAWAY on connection close');
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 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2157
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2158 sub h2_ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2159 my ($sess, $payload) = @_;
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 raw_write($sess->{socket}, pack("x2C2x5a8", 8, 0x6, $payload));
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 h2_rst {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2165 my ($sess, $stream, $error) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2166
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2167 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2168 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2169
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2170 sub h2_priority {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2171 my ($sess, $w, $stream, $dep) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2172
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2173 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2174 $dep = 0 unless defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2175 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2176 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2177
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2178 sub h2_window {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2179 my ($sess, $win, $stream) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2180
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2181 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2182 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x8, $stream, $win));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2183 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2184
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2185 sub h2_settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2186 my ($sess, $ack, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2187
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2188 my $len = 6 * keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2189 my $buf = pack_length($len) . pack "CCx4", 0x4, $ack ? 0x1 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2190 $buf .= join '', map { pack "nN", $_, $extra{$_} } keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2191 raw_write($sess->{socket}, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2192 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2193
697
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2194 sub h2_unknown {
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2195 my ($sess, $payload) = @_;
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2196
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2197 my $buf = pack_length(length($payload)) . pack("Cx5a*", 0xa, $payload);
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2198 raw_write($sess->{socket}, $buf);
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2199 }
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2200
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2201 sub h2_continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2202 my ($ctx, $stream, $uri) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2203
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2204 $uri->{h2_continue} = 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2205 return new_stream($ctx, $uri, $stream);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2206 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2207
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2208 sub new_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2209 my ($ctx, $uri, $stream) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2210 my ($input, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2211 my ($d, $status);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2212
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2213 $ctx->{headers} = '';
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2214
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2215 my $host = $uri->{host} || '127.0.0.1:8080';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2216 my $method = $uri->{method} || 'GET';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2217 my $scheme = $uri->{scheme} || 'http';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2218 my $path = $uri->{path} || '/';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2219 my $headers = $uri->{headers};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2220 my $body = $uri->{body};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2221 my $prio = $uri->{prio};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2222 my $dep = $uri->{dep};
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2223 my $split = ref $uri->{continuation} && $uri->{continuation} || [];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2224
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2225 my $pad = defined $uri->{padding} ? $uri->{padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2226 my $padlen = defined $uri->{padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2227 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2228 my $bpadlen = defined $uri->{body_padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2229
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2230 my $type = defined $uri->{h2_continue} ? 0x9 : 0x1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2231 my $flags = defined $uri->{continuation} ? 0x0 : 0x4;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2232 $flags |= 0x1 unless defined $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2233 $flags |= 0x8 if $padlen;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2234 $flags |= 0x20 if defined $dep || defined $prio;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2235
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2236 if ($stream) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2237 $ctx->{last_stream} = $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2238 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2239 $ctx->{last_stream} += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2240 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2241
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2242 $buf = pack("xxx"); # Length stub
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2243 $buf .= pack("CC", $type, $flags); # END_HEADERS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2244 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2245
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2246 $dep = 0 if defined $prio and not defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2247 $prio = 16 if defined $dep and not defined $prio;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2248
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2249 unless ($headers) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2250 $input = hpack($ctx, ":method", $method);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2251 $input .= hpack($ctx, ":scheme", $scheme);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2252 $input .= hpack($ctx, ":path", $path);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2253 $input .= hpack($ctx, ":authority", $host);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2254 $input .= hpack($ctx, "content-length", length($body)) if $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2255
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2256 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2257 $input = join '', map {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2258 hpack($ctx, $_->{name}, $_->{value},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2259 mode => $_->{mode}, huff => $_->{huff})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2260 } @$headers if $headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2261 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2262
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2263 $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2264 if defined $uri->{table_size};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2265
702
cc2b98d028c8 Tests: fixed HTTP/2 test for CONTINUATION while in header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 700
diff changeset
2266 my @input = map { substr $input, 0, $_, "" } @$split;
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2267 push @input, $input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2268
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2269 # set length, attach headers, padding, priority
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2270
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2271 my $hlen = length($input[0]) + $pad + $padlen;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2272 $hlen += 5 if $flags & 0x20;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2273 $buf |= pack_length($hlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2274
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2275 $buf .= pack 'C', $pad if $padlen; # Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2276 $buf .= pack 'NC', $dep, $prio if $flags & 0x20;
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2277 $buf .= $input[0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2278 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2279
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2280 shift @input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2281
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2282 while (@input) {
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2283 $input = shift @input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2284 $flags = @input ? 0x0 : 0x4;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2285 $buf .= pack_length(length($input));
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2286 $buf .= pack("CC", 0x9, $flags);
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2287 $buf .= pack("N", $ctx->{last_stream});
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2288 $buf .= $input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2289 }
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2290
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2291 if (defined $body) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2292 $buf .= pack_length(length($body) + $bpad + $bpadlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2293 my $flags = $bpadlen ? 0x8 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2294 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2295 $buf .= pack 'N', $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2296 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2297 $buf .= $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2298 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2299 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2300
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2301 $split = ref $uri->{split} && $uri->{split} || [];
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2302 for (@$split) {
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2303 raw_write($ctx->{socket}, substr($buf, 0, $_, ""));
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2304 select undef, undef, undef, 0.2;
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2305 }
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2306
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2307 raw_write($ctx->{socket}, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2308 return $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2309 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2310
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2311 sub h2_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2312 my ($sess, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2313 my (@got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2314 my $s = $sess->{socket};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2315 my $buf = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2316
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2317 while (1) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2318 $buf = raw_read($s, $buf, 9);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2319 last unless length $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2320
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2321 my $length = unpack_length($buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2322 my $type = unpack('x3C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2323 my $flags = unpack('x4C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2324
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2325 my $stream = unpack "x5 B32", $buf;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2326 substr($stream, 0, 1) = 0;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2327 $stream = unpack("N", pack("B32", $stream));
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2328
679
b60c1a207675 Tests: fixed HTTP/2 tests with large frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 677
diff changeset
2329 $buf = raw_read($s, $buf, $length + 9);
724
4322541b80ed Tests: avoid uninitialized warnings in h2.t with partial frame.
Sergey Kandaurov <pluknet@nginx.com>
parents: 723
diff changeset
2330 last if length($buf) < $length + 9;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2331
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2332 $buf = substr($buf, 9);
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2333
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2334 my $frame = $cframe{$type}{value}($sess, $buf, $length, $flags);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2335 $frame->{length} = $length;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2336 $frame->{type} = $cframe{$type}{name};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2337 $frame->{flags} = $flags;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2338 $frame->{sid} = $stream;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2339 push @got, $frame;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2340
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2341 $buf = substr($buf, $length);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2342
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2343 last unless test_fin($got[-1], $extra{all});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2344 };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2345 return \@got;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2346 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2347
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2348 sub test_fin {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2349 my ($frame, $all) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2350 my @test = @{$all};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2351
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2352 # wait for the specified DATA length
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2353
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2354 for (@test) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2355 if ($_->{length} && $frame->{type} eq 'DATA') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2356 # check also for StreamID if needed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2357
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2358 if (!$_->{sid} || $_->{sid} == $frame->{sid}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2359 $_->{length} -= $frame->{length};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2360 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2361 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2362 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2363 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2364
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2365 # wait for the fin flag
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2366
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2367 @test = grep { !(defined $_->{fin}
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2368 && $_->{sid} == $frame->{sid} && $_->{fin} & $frame->{flags})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2369 } @test if defined $frame->{flags};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2370
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2371 # wait for the specified frame
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2372
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2373 @test = grep { !($_->{type} && $_->{type} eq $frame->{type}) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2374
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2375 @{$all} = @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2376 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2377
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2378 sub headers {
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2379 my ($ctx, $buf, $len, $flags) = @_;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2380 $ctx->{headers} .= substr($buf, 0, $len);
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2381 return unless $flags & 0x4;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2382 { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2383 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2384
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2385 sub data {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2386 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2387 return { data => substr($buf, 0, $len) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2388 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2389
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2390 sub settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2391 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2392 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2393 my $skip = 0;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2394
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2395 for (1 .. $len / 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2396 my $id = hex unpack "\@$skip n", $buf; $skip += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2397 $payload{$id} = unpack "\@$skip N", $buf; $skip += 4;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2398 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2399 return \%payload;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2400 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2401
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2402 sub ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2403 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
2404 return { value => unpack "A$len", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2405 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2406
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2407 sub rst_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2408 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2409 return { code => unpack "N", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2410 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2411
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2412 sub goaway {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2413 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2414 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2415
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2416 my $stream = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2417 substr($stream, 0, 1) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2418 $stream = unpack("N", pack("B32", $stream));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2419 $payload{last_sid} = $stream;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2420
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2421 $len -= 4;
670
944b87756cab Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 669
diff changeset
2422 $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
2423 $payload{debug} = unpack "x8 A$len", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2424 return \%payload;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2425 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2426
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2427 sub window_update {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2428 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2429 my $value = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2430 substr($value, 0, 1) = 0;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2431 return { wdelta => unpack("N", pack("B32", $value)) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2432 }
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 sub pack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2435 pack 'c3', unpack 'xc3', pack 'N', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2436 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2437
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2438 sub unpack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2439 unpack 'N', pack 'xc3', unpack 'c3', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2440 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2441
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2442 sub raw_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2443 my ($s, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2444 my $got = '';
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 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
2447 $s->sysread($got, 16384) or last;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2448 log_in($got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2449 $buf .= $got;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2450 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2451 return $buf;
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 sub raw_write {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2455 my ($s, $message) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2456
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2457 local $SIG{PIPE} = 'IGNORE';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2458
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2459 while (IO::Select->new($s)->can_write(0.4)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2460 log_out($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2461 my $n = $s->syswrite($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2462 last unless $n;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2463 $message = substr($message, $n);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2464 last unless length $message;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2465 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2466 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2467
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2468 sub new_session {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2469 my ($port, %extra) = @_;
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2470
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2471 my $s = new_socket($port, %extra);
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2472 my $preface = $extra{preface}
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2473 || 'PRI * HTTP/2.0' . CRLF . CRLF . 'SM' . CRLF . CRLF;
646
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 if ($extra{proxy}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2476 raw_write($s, $extra{proxy});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2477 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2478
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2479 # preface
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2480
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2481 raw_write($s, $preface);
646
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 return { socket => $s, last_stream => -1,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2484 dynamic_encode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2485 dynamic_decode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2486 static_table_size => scalar @{[static_table()]} };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2487 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2488
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2489 sub new_socket {
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2490 my ($port, %extra) = @_;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2491 my $npn = $extra{'npn'};
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2492 my $alpn = $extra{'alpn'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2493 my $s;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2494
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2495 $port = 8080 unless defined $port;
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 eval {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2498 local $SIG{ALRM} = sub { die "timeout\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2499 local $SIG{PIPE} = sub { die "sigpipe\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2500 alarm(2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2501 $s = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2502 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2503 PeerAddr => "127.0.0.1:$port",
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2504 );
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2505 IO::Socket::SSL->start_SSL($s,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2506 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
2507 SSL_npn_protocols => $npn ? [ $npn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2508 SSL_alpn_protocols => $alpn ? [ $alpn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2509 SSL_error_trap => sub { die $_[1] }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2510 ) if $extra{'SSL'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2511 alarm(0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2512 };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2513 alarm(0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2514
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2515 if ($@) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2516 log_in("died: $@");
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2517 return undef;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2518 }
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 return $s;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2523 sub static_table {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2524 [ '', '' ], # unused
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2525 [ ':authority', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2526 [ ':method', 'GET' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2527 [ ':method', 'POST' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2528 [ ':path', '/' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2529 [ ':path', '/index.html' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2530 [ ':scheme', 'http' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2531 [ ':scheme', 'https' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2532 [ ':status', '200' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2533 [ ':status', '204' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2534 [ ':status', '206' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2535 [ ':status', '304' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2536 [ ':status', '400' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2537 [ ':status', '404' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2538 [ ':status', '500' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2539 [ 'accept-charset', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2540 [ 'accept-encoding', 'gzip, deflate' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2541 [ 'accept-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2542 [ 'accept-ranges', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2543 [ 'accept', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2544 [ 'access-control-allow-origin',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2545 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2546 [ 'age', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2547 [ 'allow', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2548 [ 'authorization', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2549 [ 'cache-control', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2550 [ 'content-disposition',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2551 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2552 [ 'content-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2553 [ 'content-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2554 [ 'content-length', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2555 [ 'content-location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2556 [ 'content-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2557 [ 'content-type', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2558 [ 'cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2559 [ 'date', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2560 [ 'etag', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2561 [ 'expect', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2562 [ 'expires', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2563 [ 'from', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2564 [ 'host', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2565 [ 'if-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2566 [ 'if-modified-since', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2567 [ 'if-none-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2568 [ 'if-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2569 [ 'if-unmodified-since',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2570 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2571 [ 'last-modified', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2572 [ 'link', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2573 [ 'location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2574 [ 'max-forwards', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2575 [ 'proxy-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2576 [ 'proxy-authorization',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2577 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2578 [ 'range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2579 [ 'referer', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2580 [ 'refresh', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2581 [ 'retry-after', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2582 [ 'server', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2583 [ 'set-cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2584 [ 'strict-transport-security',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2585 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2586 [ 'transfer-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2587 [ 'user-agent', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2588 [ 'vary', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2589 [ 'via', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2590 [ 'www-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2591 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2592
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2593 # RFC 7541, 5.1. Integer Representation
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2594
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2595 sub ipack {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2596 my ($base, $d) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2597 return sprintf("%.*b", $base, $d) if $d < 2**$base - 1;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2598
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2599 my $o = sprintf("%${base}b", 2**$base - 1);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2600 $d -= 2**$base - 1;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2601 while ($d >= 128) {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2602 $o .= sprintf("%8b", $d % 128 + 128);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2603 $d /= 128;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2604 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2605 $o .= sprintf("%08b", $d);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2606 return $o;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2607 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2608
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2609 sub iunpack {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2610 my ($base, $b, $s) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2611
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2612 my $len = unpack("\@$s B8", $b); $s++;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2613 my $prefix = substr($len, 0, 8 - $base);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2614 $len = '0' x (8 - $base) . substr($len, 8 - $base);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2615 $len = unpack("C", pack("B8", $len));
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2616
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2617 return ($len, $s, $prefix) if $len < 2**$base - 1;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2618
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2619 my $m = 0;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2620 my $d;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2621
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2622 do {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2623 $d = unpack("\@$s C", $b); $s++;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2624 $len += ($d & 127) * 2**$m;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2625 $m += $base;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2626 } while (($d & 128) == 128);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2627
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2628 return ($len, $s, $prefix);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2629 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2630
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2631 sub hpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2632 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
2633 my $table = $ctx->{dynamic_encode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2634 my $mode = defined $extra{mode} ? $extra{mode} : 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2635 my $huff = $extra{huff};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2636
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2637 my ($index, $buf) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2638
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2639 # 6.1. Indexed Header Field Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2640
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2641 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
2642 ++$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
2643 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
2644 and $table->[$index][1] eq $value;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2645 $buf = pack('B*', '1' . ipack(7, $index));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2646 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2647
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2648 # 6.2.1. Literal Header Field with Incremental Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2649
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2650 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
2651 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
2652
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2653 ++$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
2654 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2655 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2656
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2657 $buf = pack('B*', '01' . ipack(6, $index)
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2658 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2659 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2660 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2661
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2662 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2663
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2664 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
2665 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2666
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2667 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2668 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2669 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2670
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2671 $buf = pack('B*', '01000000');
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2672 $buf .= pack('B*', $hbit . ipack(7, length($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2673 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2674 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2675 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2676 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2677
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2678 # 6.2.2. Literal Header Field without Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2679
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2680 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
2681 ++$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
2682 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2683 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2684
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2685 $buf = pack('B*', '0000' . ipack(4, $index)
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2686 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2687 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2688 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2689
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2690 # 6.2.2. Literal Header Field without Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2691
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2692 if ($mode == 4) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2693 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2694 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2695 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2696
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2697 $buf = pack('B*', '00000000');
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2698 $buf .= pack('B*', $hbit . ipack(7, length($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2699 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2700 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2701 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2702 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2703
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2704 # 6.2.3. Literal Header Field Never Indexed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2705
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2706 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
2707 ++$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
2708 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2709 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2710
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2711 $buf = pack('B*', '0001' . ipack(4, $index)
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2712 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2713 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2714 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2715
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2716 # 6.2.3. Literal Header Field Never Indexed -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2717
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2718 if ($mode == 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2719 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2720 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2721 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2722
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2723 $buf = pack('B*', '00010000');
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2724 $buf .= pack('B*', $hbit . ipack(7, length($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2725 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2726 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2727 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2728 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2729
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2730 return $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2731 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2732
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2733 sub hunpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2734 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
2735 my $table = $ctx->{dynamic_decode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2736 my %headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2737 my $skip = 0;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2738 my ($index, $name, $value);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2739
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2740 my $field = sub {
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2741 my ($b) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2742 my ($len, $s, $huff) = iunpack(7, @_);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2743
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2744 my $field = substr($b, $s, $len);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2745 $field = $huff ? dehuff($field) : $field;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2746 $s += $len;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2747 return ($field, $s);
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2748 };
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2749
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2750 my $add = sub {
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2751 my ($h, $n, $v) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2752 return $h->{$n} = $v unless exists $h->{$n};
717
3b6ff3b7367d Tests: fixed multiple header field values representation in h2.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 716
diff changeset
2753 $h->{$n} = [ $h->{$n} ] unless ref $h->{$n};
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
2754 push @{$h->{$n}}, $v;
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2755 };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2756
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2757 while ($skip < $length) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2758 my $ib = unpack("\@$skip B8", $data);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2759
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2760 if (substr($ib, 0, 1) eq '1') {
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2761 ($index, $skip) = iunpack(7, $data, $skip);
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2762 $add->(\%headers,
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2763 $table->[$index][0], $table->[$index][1]);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2764 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2765 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2766
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2767 if (substr($ib, 0, 2) eq '01') {
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2768 ($index, $skip) = iunpack(6, $data, $skip);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2769 $name = $table->[$index][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2770
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2771 ($name, $skip) = $field->($data, $skip) unless $name;
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2772 ($value, $skip) = $field->($data, $skip);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2773
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2774 splice @$table,
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2775 $ctx->{static_table_size}, 0, [ $name, $value ];
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2776 $add->(\%headers, $name, $value);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2777 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2778 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2779
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2780 if (substr($ib, 0, 4) eq '0000') {
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2781 ($index, $skip) = iunpack(4, $data, $skip);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2782 $name = $table->[$index][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2783
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2784 ($name, $skip) = $field->($data, $skip) unless $name;
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2785 ($value, $skip) = $field->($data, $skip);
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2786
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2787 $add->(\%headers, $name, $value);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2788 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2789 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2790 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2791
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2792 return \%headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2793 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2794
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2795 sub huff_code { scalar {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2796 pack('C', 0) => '1111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2797 pack('C', 1) => '11111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2798 pack('C', 2) => '1111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2799 pack('C', 3) => '1111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2800 pack('C', 4) => '1111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2801 pack('C', 5) => '1111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2802 pack('C', 6) => '1111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2803 pack('C', 7) => '1111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2804 pack('C', 8) => '1111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2805 pack('C', 9) => '111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2806 pack('C', 10) => '111111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2807 pack('C', 11) => '1111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2808 pack('C', 12) => '1111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2809 pack('C', 13) => '111111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2810 pack('C', 14) => '1111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2811 pack('C', 15) => '1111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2812 pack('C', 16) => '1111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2813 pack('C', 17) => '1111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2814 pack('C', 18) => '1111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2815 pack('C', 19) => '1111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2816 pack('C', 20) => '1111111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2817 pack('C', 21) => '1111111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2818 pack('C', 22) => '111111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2819 pack('C', 23) => '1111111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2820 pack('C', 24) => '1111111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2821 pack('C', 25) => '1111111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2822 pack('C', 26) => '1111111111111111111111110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2823 pack('C', 27) => '1111111111111111111111110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2824 pack('C', 28) => '1111111111111111111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2825 pack('C', 29) => '1111111111111111111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2826 pack('C', 30) => '1111111111111111111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2827 pack('C', 31) => '1111111111111111111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2828 pack('C', 32) => '010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2829 pack('C', 33) => '1111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2830 pack('C', 34) => '1111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2831 pack('C', 35) => '111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2832 pack('C', 36) => '1111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2833 pack('C', 37) => '010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2834 pack('C', 38) => '11111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2835 pack('C', 39) => '11111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2836 pack('C', 40) => '1111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2837 pack('C', 41) => '1111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2838 pack('C', 42) => '11111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2839 pack('C', 43) => '11111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2840 pack('C', 44) => '11111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2841 pack('C', 45) => '010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2842 pack('C', 46) => '010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2843 pack('C', 47) => '011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2844 pack('C', 48) => '00000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2845 pack('C', 49) => '00001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2846 pack('C', 50) => '00010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2847 pack('C', 51) => '011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2848 pack('C', 52) => '011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2849 pack('C', 53) => '011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2850 pack('C', 54) => '011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2851 pack('C', 55) => '011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2852 pack('C', 56) => '011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2853 pack('C', 57) => '011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2854 pack('C', 58) => '1011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2855 pack('C', 59) => '11111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2856 pack('C', 60) => '111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2857 pack('C', 61) => '100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2858 pack('C', 62) => '111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2859 pack('C', 63) => '1111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2860 pack('C', 64) => '1111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2861 pack('C', 65) => '100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2862 pack('C', 66) => '1011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2863 pack('C', 67) => '1011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2864 pack('C', 68) => '1011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2865 pack('C', 69) => '1100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2866 pack('C', 70) => '1100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2867 pack('C', 71) => '1100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2868 pack('C', 72) => '1100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2869 pack('C', 73) => '1100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2870 pack('C', 74) => '1100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2871 pack('C', 75) => '1100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2872 pack('C', 76) => '1100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2873 pack('C', 77) => '1101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2874 pack('C', 78) => '1101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2875 pack('C', 79) => '1101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2876 pack('C', 80) => '1101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2877 pack('C', 81) => '1101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2878 pack('C', 82) => '1101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2879 pack('C', 83) => '1101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2880 pack('C', 84) => '1101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2881 pack('C', 85) => '1110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2882 pack('C', 86) => '1110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2883 pack('C', 87) => '1110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2884 pack('C', 88) => '11111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2885 pack('C', 89) => '1110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2886 pack('C', 90) => '11111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2887 pack('C', 91) => '1111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2888 pack('C', 92) => '1111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2889 pack('C', 93) => '1111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2890 pack('C', 94) => '11111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2891 pack('C', 95) => '100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2892 pack('C', 96) => '111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2893 pack('C', 97) => '00011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2894 pack('C', 98) => '100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2895 pack('C', 99) => '00100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2896 pack('C', 100) => '100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2897 pack('C', 101) => '00101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2898 pack('C', 102) => '100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2899 pack('C', 103) => '100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2900 pack('C', 104) => '100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2901 pack('C', 105) => '00110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2902 pack('C', 106) => '1110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2903 pack('C', 107) => '1110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2904 pack('C', 108) => '101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2905 pack('C', 109) => '101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2906 pack('C', 110) => '101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2907 pack('C', 111) => '00111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2908 pack('C', 112) => '101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2909 pack('C', 113) => '1110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2910 pack('C', 114) => '101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2911 pack('C', 115) => '01000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2912 pack('C', 116) => '01001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2913 pack('C', 117) => '101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2914 pack('C', 118) => '1110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2915 pack('C', 119) => '1111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2916 pack('C', 120) => '1111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2917 pack('C', 121) => '1111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2918 pack('C', 122) => '1111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2919 pack('C', 123) => '111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2920 pack('C', 124) => '11111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2921 pack('C', 125) => '11111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2922 pack('C', 126) => '1111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2923 pack('C', 127) => '1111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2924 pack('C', 128) => '11111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2925 pack('C', 129) => '1111111111111111010010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2926 pack('C', 130) => '11111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2927 pack('C', 131) => '11111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2928 pack('C', 132) => '1111111111111111010011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2929 pack('C', 133) => '1111111111111111010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2930 pack('C', 134) => '1111111111111111010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2931 pack('C', 135) => '11111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2932 pack('C', 136) => '1111111111111111010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2933 pack('C', 137) => '11111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2934 pack('C', 138) => '11111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2935 pack('C', 139) => '11111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2936 pack('C', 140) => '11111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2937 pack('C', 141) => '11111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2938 pack('C', 142) => '111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2939 pack('C', 143) => '11111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2940 pack('C', 144) => '111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2941 pack('C', 145) => '111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2942 pack('C', 146) => '1111111111111111010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2943 pack('C', 147) => '11111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2944 pack('C', 148) => '111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2945 pack('C', 149) => '11111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2946 pack('C', 150) => '11111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2947 pack('C', 151) => '11111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2948 pack('C', 152) => '11111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2949 pack('C', 153) => '111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2950 pack('C', 154) => '1111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2951 pack('C', 155) => '11111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2952 pack('C', 156) => '1111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2953 pack('C', 157) => '11111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2954 pack('C', 158) => '11111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2955 pack('C', 159) => '111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2956 pack('C', 160) => '1111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2957 pack('C', 161) => '111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2958 pack('C', 162) => '11111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2959 pack('C', 163) => '1111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2960 pack('C', 164) => '1111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2961 pack('C', 165) => '11111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2962 pack('C', 166) => '11111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2963 pack('C', 167) => '111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2964 pack('C', 168) => '11111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2965 pack('C', 169) => '1111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2966 pack('C', 170) => '1111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2967 pack('C', 171) => '111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2968 pack('C', 172) => '111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2969 pack('C', 173) => '1111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2970 pack('C', 174) => '11111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2971 pack('C', 175) => '11111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2972 pack('C', 176) => '111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2973 pack('C', 177) => '111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2974 pack('C', 178) => '1111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2975 pack('C', 179) => '111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2976 pack('C', 180) => '11111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2977 pack('C', 181) => '1111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2978 pack('C', 182) => '11111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2979 pack('C', 183) => '11111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2980 pack('C', 184) => '11111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2981 pack('C', 185) => '1111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2982 pack('C', 186) => '1111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2983 pack('C', 187) => '1111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2984 pack('C', 188) => '11111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2985 pack('C', 189) => '1111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2986 pack('C', 190) => '1111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2987 pack('C', 191) => '11111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2988 pack('C', 192) => '11111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2989 pack('C', 193) => '11111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2990 pack('C', 194) => '11111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2991 pack('C', 195) => '1111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2992 pack('C', 196) => '1111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2993 pack('C', 197) => '11111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2994 pack('C', 198) => '1111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2995 pack('C', 199) => '1111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2996 pack('C', 200) => '11111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2997 pack('C', 201) => '11111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2998 pack('C', 202) => '11111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2999 pack('C', 203) => '111111111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3000 pack('C', 204) => '111111111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3001 pack('C', 205) => '11111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3002 pack('C', 206) => '111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3003 pack('C', 207) => '1111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3004 pack('C', 208) => '1111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3005 pack('C', 209) => '111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3006 pack('C', 210) => '11111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3007 pack('C', 211) => '111111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3008 pack('C', 212) => '111111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3009 pack('C', 213) => '11111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3010 pack('C', 214) => '111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3011 pack('C', 215) => '111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3012 pack('C', 216) => '111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3013 pack('C', 217) => '111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3014 pack('C', 218) => '11111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3015 pack('C', 219) => '11111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3016 pack('C', 220) => '1111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3017 pack('C', 221) => '111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3018 pack('C', 222) => '111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3019 pack('C', 223) => '111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3020 pack('C', 224) => '11111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3021 pack('C', 225) => '111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3022 pack('C', 226) => '11111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3023 pack('C', 227) => '111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3024 pack('C', 228) => '1111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3025 pack('C', 229) => '111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3026 pack('C', 230) => '111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3027 pack('C', 231) => '11111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3028 pack('C', 232) => '1111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3029 pack('C', 233) => '1111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3030 pack('C', 234) => '1111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3031 pack('C', 235) => '1111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3032 pack('C', 236) => '111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3033 pack('C', 237) => '111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3034 pack('C', 238) => '11111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3035 pack('C', 239) => '11111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3036 pack('C', 240) => '11111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3037 pack('C', 241) => '111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3038 pack('C', 242) => '11111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3039 pack('C', 243) => '11111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3040 pack('C', 244) => '111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3041 pack('C', 245) => '111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3042 pack('C', 246) => '111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3043 pack('C', 247) => '111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3044 pack('C', 248) => '111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3045 pack('C', 249) => '1111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3046 pack('C', 250) => '111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3047 pack('C', 251) => '111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3048 pack('C', 252) => '111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3049 pack('C', 253) => '111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3050 pack('C', 254) => '111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3051 pack('C', 255) => '11111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3052 '_eos' => '111111111111111111111111111111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3053 }};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3054
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3055 sub huff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3056 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3057 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3058
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3059 my $ret = join '', map { $code->{$_} } (split //, $string);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3060 my $len = length($ret) + (8 - length($ret) % 8);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3061 $ret .= $code->{_eos};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3062
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3063 return pack("B$len", $ret);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3064 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3065
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3066 sub dehuff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3067 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3068 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3069 my %decode = reverse %$code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3070
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3071 my $ret = ''; my $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3072 for (split //, unpack('B*', $string)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3073 $c .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3074 next unless exists $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3075 last if $decode{$c} eq '_eos';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3076
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3077 $ret .= $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3078 $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3079 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3080
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3081 return $ret;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3082 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3083
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3084 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3085
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3086 sub gunzip_like {
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3087 my ($in, $re, $name) = @_;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3088
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3089 SKIP: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3090 eval { require IO::Uncompress::Gunzip; };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3091 Test::More::skip(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3092 "IO::Uncompress::Gunzip not installed", 1) if $@;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3093
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3094 my $out;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3095
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3096 IO::Uncompress::Gunzip::gunzip(\$in => \$out);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3097
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3098 like($out, $re, $name);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3099 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3100 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3101
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3102 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3103
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3104 # for tests with multiple header fields
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3105
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3106 sub http_daemon {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3107 my $server = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3108 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3109 LocalHost => '127.0.0.1',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3110 LocalPort => 8083,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3111 Listen => 5,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3112 Reuse => 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3113 )
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3114 or die "Can't create listening socket: $!\n";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3115
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3116 local $SIG{PIPE} = 'IGNORE';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3117
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3118 while (my $client = $server->accept()) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3119 $client->autoflush(1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3120
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3121 my $headers = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3122 my $uri = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3123
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3124 while (<$client>) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3125 $headers .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3126 last if (/^\x0d?\x0a?$/);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3127 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3128
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3129 next if $headers eq '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3130 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3131
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3132 if ($uri eq '/cookie') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3133
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3134 my ($cookie, $cookie2) = $headers =~ /Cookie: (.+)/ig;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3135 $cookie2 = '' unless defined $cookie2;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3136
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3137 my ($cookie_a, $cookie_c) = ('', '');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3138 $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
3139 $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
3140
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3141 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3142 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3143 Connection: close
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3144 X-Sent-Cookie: $cookie
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3145 X-Sent-Cookie2: $cookie2
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3146 X-Sent-Cookie-a: $cookie_a
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3147 X-Sent-Cookie-c: $cookie_c
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3148
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3149 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3150
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3151 } elsif ($uri eq '/set-cookie') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3152
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3153 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3154 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3155 Connection: close
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3156 Set-Cookie: a=b
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3157 Set-Cookie: c=d
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3158
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3159 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3160
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3161 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3162
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3163 } continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3164 close $client;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3165 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3166 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3167
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3168 ###############################################################################