annotate h2.t @ 736:dcbe4c3d6871

Tests: added HTTP/2 tests for HPACK table boundary.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 19 Oct 2015 17:00:24 +0300
parents 832cd7cc8f53
children abf42eb6cf48
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/)
736
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
35 ->has_daemon('openssl')->plan(222);
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
560 # 6.3. Dynamic Table Size Update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
561
653
5ad620022234 Tests: HTTP/2 tests adapted to send ':authority' where needed.
Sergey Kandaurov <pluknet@nginx.com>
parents: 652
diff changeset
562 # 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
563 # by maintaining dynamic table space only for index 0
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
564 # 'x-foo' has index 0, and 'referer' has index 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
565
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
566 $sid = new_stream($sess, { table_size => 61, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
567 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
568 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
569 { 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
570 { 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
571 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
572 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
573
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
574 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
575 isnt($frame, undef, 'updated table size - remaining index');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
576
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
577 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
578 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
579 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
580 { 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
581 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
582 { name => 'referer', value => 'foo', mode => 0 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
583 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
584
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
585 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
586 is($frame, undef, 'invalid index');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
587
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
588 # 5.4.1. Connection Error Handling
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
589 # An endpoint that encounters a connection error SHOULD first send a
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
590 # GOAWAY frame <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
591
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
592 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
672
66f94d6c5047 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 671
diff changeset
593 ok($frame, 'invalid index - GOAWAY');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
594
691
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
595 # 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
596 # 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
597 # 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
598
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
599 # 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
600 # 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
601 # 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
602
3f4a132c6463 Tests: extended HTTP/2 tests for GOAWAY on compression error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 685
diff changeset
603 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
604 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
605
729
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
606 # invalid table size update
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
607
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
608 $sess = new_session();
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
609 $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
610 { 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
611 { 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
612 { 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
613 { 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
614 { 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
615 $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
616
41caaaff9b95 Tests: added HTTP/2 tests for invalid table size update.
Sergey Kandaurov <pluknet@nginx.com>
parents: 728
diff changeset
617 ($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
618 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
619 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
620 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
621
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
622 # HEAD
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
623
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
624 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
625 $sid = new_stream($sess, { method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
626 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
627
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
628 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
629 is($frame->{sid}, $sid, 'HEAD - HEADERS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
630 is($frame->{headers}->{':status'}, 200, 'HEAD - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
631 is($frame->{headers}->{'x-header'}, 'X-Foo', 'HEAD - HEADERS header');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
632
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
633 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
634 is($frame, undef, 'HEAD - no body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
635
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
636 # GET with PROXY protocol
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
637
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
638 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
639 $sess = new_session(8082, proxy => $proxy);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
640 $sid = new_stream($sess, { path => '/pp' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
641 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
642
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
643 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
644 ok($frame, 'PROXY HEADERS frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
645 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
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
647 # range filter
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
648
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
649 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
650 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
651 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
652 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
653 { 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
654 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
655 { name => 'range', value => 'bytes=10-19', mode => 1 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
656 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
657
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
658 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
659 is($frame->{headers}->{':status'}, 206, 'range - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
660
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
661 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
662 is($frame->{length}, 10, 'range - DATA length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
663 is($frame->{data}, '002XXXX000', 'range - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
664
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
665 # $http2
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
666
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
667 $sess = new_session();
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
668 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
669 $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
670
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
671 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
672 is($frame->{data}, 'h2c', 'http variable - h2c');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
673
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
674 # SSL/TLS connection, NPN
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
675
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
676 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
677 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
678 skip 'OpenSSL NPN support required', 1 if $@;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
679
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
680 $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
681 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
682 $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
683
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
684 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
685 is($frame->{data}, 'h2', 'http variable - npn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
686
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
687 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
688
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
689 # SSL/TLS connection, ALPN
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 SKIP: {
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
692 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
693 skip 'OpenSSL ALPN support required', 1 if $@;
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 $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
696 $sid = new_stream($sess, { path => '/h2' });
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
697 $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
698
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
699 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
700 is($frame->{data}, 'h2', 'http variable - alpn');
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
701
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
702 }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
703
716
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
704 # $server_protocol
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
705
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
706 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
707 $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
708 $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
709
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
710 ($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
711 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
712
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
713 # $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
714
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
715 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
716 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
717 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
718
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
719 $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
720 $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
721 $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
722
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
723 ($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
724 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
725
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
726 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
727
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
728 # $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
729
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
730 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
731 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
732 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
733
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
734 $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
735 $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
736 $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
737
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
738 ($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
739 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
740
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
741 }
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 # $scheme
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
744
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
745 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
746 $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
747 $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
748
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
749 ($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
750 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
751
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
752 # $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
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_npn() 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 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
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, npn => '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 => '/scheme' });
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}, '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
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 - 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
768
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
769 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
770 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
771 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
772
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
773 $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
774 $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
775 $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
776
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
777 ($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
778 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
779
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
780 }
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 # $https
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
783
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
784 $sess = new_session();
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
785 $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
786 $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
787
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
788 ($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
789 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
790
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
791 # $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
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_npn() 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 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
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, npn => '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 => '/https' });
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}, '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
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 - 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
807
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
808 SKIP: {
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
809 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
810 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
811
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
812 $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
813 $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
814 $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
815
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
816 ($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
817 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
818
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
819 }
e3fd2c8d257e Tests: added HTTP/2 tests for some http core module variables.
Sergey Kandaurov <pluknet@nginx.com>
parents: 715
diff changeset
820
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
821 # http2_chunk_size=1
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
822
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
823 $sess = new_session();
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
824 $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
825 $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
826
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
827 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
828 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
829 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
830 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
831
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
832 # CONTINUATION
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
833
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
834 $sess = new_session();
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
835 $sid = new_stream($sess, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
836 { name => ':method', value => 'HEAD', mode => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
837 { 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
838 { 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
839 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
840 h2_continue($sess, $sid, { continuation => 1, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
841 { name => 'x-foo', value => 'X-Bar', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
842 h2_continue($sess, $sid, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
843 { name => 'referer', value => 'foo', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
844 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
845
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
846 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
847 is($frame, undef, 'CONTINUATION - fragment 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
848
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
849 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
850 is($frame->{headers}->{'x-sent-foo'}, 'X-Bar', 'CONTINUATION - fragment 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
851 is($frame->{headers}->{'x-referer'}, 'foo', 'CONTINUATION - fragment 3');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
852
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
853 # 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
854
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
855 $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
856 $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
857 { 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
858 { 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
859 { 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
860 { 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
861 $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
862
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
863 ($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
864 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
865
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
866 # frame padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
867
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
868 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
869 $sid = new_stream($sess, { padding => 42, headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
870 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
871 { 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
872 { 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
873 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
874 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
875
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
876 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
877 is($frame->{headers}->{':status'}, 200, 'padding - HEADERS status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
878
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
879 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
880 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
881 { 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
882 { 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
883 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
884 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
885
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
886 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
887 is($frame->{headers}->{':status'}, 200, 'padding - next stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
888
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
889 # request header field with multiple values
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
890
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
891 # 8.1.2.5. Compressing the Cookie Header Field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
892 # To allow for better compression efficiency, the Cookie header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
893 # MAY be split into separate header fields <..>.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
894
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
895 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
896 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
897 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
898 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
899 { 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
900 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
901 { name => 'cookie', value => 'a=b', mode => 2},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
902 { name => 'cookie', value => 'c=d', mode => 2}]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
903 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
904
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
905 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
906 is($frame->{headers}->{'x-cookie-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
907 'multiple request header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
908 is($frame->{headers}->{'x-cookie-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
909 'multiple request header fields - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
910 is($frame->{headers}->{'x-cookie'}, 'a=b; c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
911 'multiple request header fields - semi-colon');
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 to HTTP backend
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 # these MUST be concatenated into a single octet string
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
917 # using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
918 # 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
919 # connection <..>
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
920
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
921 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
922 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
923 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
924 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
925 { 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
926 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
927 { name => 'cookie', value => 'a=b', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
928 { name => 'cookie', value => 'c=d', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
929 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
930
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
931 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
932 is($frame->{headers}->{'x-sent-cookie'}, 'a=b; c=d',
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
933 '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
934 is($frame->{headers}->{'x-sent-cookie2'}, '',
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
935 'multiple request header fields proxied - dublicate cookie');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
936 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
937 'multiple request header fields proxied - cookie 1');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
938 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
939 'multiple request header fields proxied - cookie 2');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
940
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
941 # response header field with multiple values
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
942
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
943 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
944 $sid = new_stream($sess, { path => '/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
945 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
946
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
947 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
948 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
949 'multiple response header fields - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
950 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
951 'multiple response header fields - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
952
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
953 # response header field with multiple values from HTTP backend
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
956 $sid = new_stream($sess, { path => '/proxy/set-cookie' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
957 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
958
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
959 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
960 is($frame->{headers}->{'set-cookie'}[0], 'a=b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
961 'multiple response header proxied - cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
962 is($frame->{headers}->{'set-cookie'}[1], 'c=d',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
963 'multiple response header proxied - cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
964 is($frame->{headers}->{'x-uc-a'}, 'b',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
965 'multiple response header proxied - upstream cookie');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
966 is($frame->{headers}->{'x-uc-c'}, 'd',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
967 'multiple response header proxied - upstream cookie 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
968
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
969 # internal redirect
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
972 $sid = new_stream($sess, { path => '/redirect' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
973 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
974
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
975 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
976 is($frame->{headers}->{':status'}, 405, 'redirect - HEADERS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
977
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
978 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
979 ok($frame, 'redirect - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
980 is($frame->{data}, 'body', 'redirect - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
981
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
982 # return 301 with absolute URI
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
983
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
984 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
985 $sid = new_stream($sess, { path => '/return301_absolute' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
986 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
987
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
988 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
989 is($frame->{headers}->{':status'}, 301, 'return 301 absolute - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
990 is($frame->{headers}->{'location'}, 'text', 'return 301 absolute - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
991
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
992 # return 301 with relative URI
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
993
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
994 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
995 $sid = new_stream($sess, { path => '/return301_relative' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
996 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
997
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
998 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
999 is($frame->{headers}->{':status'}, 301, 'return 301 relative - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1000 is($frame->{headers}->{'location'}, 'http://127.0.0.1:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1001 'return 301 relative - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1002
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1003 # return 301 with relative URI and ':authority' request header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1004
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1005 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1006 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1007 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1008 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1009 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1010 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1011 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1012
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1013 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1014 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1015 'return 301 relative - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1016 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1017 'return 301 relative - authority - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1018
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1019 # return 301 with relative URI and 'host' request header field
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1020
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1021 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1022 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1023 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1024 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1025 { name => ':path', value => '/return301_relative', mode => 2 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1026 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1027 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1028
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1029 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1030 is($frame->{headers}->{':status'}, 301,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1031 'return 301 relative - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1032 is($frame->{headers}->{'location'}, 'http://localhost:8080/',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1033 'return 301 relative - host - location');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1034
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1035 # virtual host
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 $sess = new_session(8085);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1038 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1039 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1040 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1041 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1042 { name => 'host', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1043 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1046 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1047 'virtual host - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1048
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1049 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1050 is($frame->{data}, 'first', 'virtual host - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1051
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1052 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1053 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1054 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1055 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1056 { name => ':authority', value => 'localhost', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1057 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1058
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1059 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1060 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1061 'virtual host - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1062
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1063 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1064 is($frame->{data}, 'first', 'virtual host - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1065
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1066 # virtual host - second
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1067
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1068 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1069 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1070 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1071 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1072 { name => 'host', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1073 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1074
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1075 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1076 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1077 'virtual host 2 - host - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1078
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1079 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1080 is($frame->{data}, 'second', 'virtual host 2 - host - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1081
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1082 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1083 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1084 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1085 { name => ':path', value => '/', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1086 { name => ':authority', value => 'localhost2', mode => 2 }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1087 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1088
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1089 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1090 is($frame->{headers}->{':status'}, 200,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1091 'virtual host 2 - authority - status');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1092
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1093 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1094 is($frame->{data}, 'second', 'virtual host 2 - authority - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1095
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1096 # gzip tests for internal nginx version
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1097
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1098 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1099 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1100 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1101 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1102 { 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
1103 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1104 { name => 'accept-encoding', value => 'gzip' }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1105 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1106
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1107 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1108 is($frame->{headers}->{'content-encoding'}, 'gzip', 'gzip - encoding');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1109
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1110 ($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
1111 gunzip_like($frame->{data}, qr/^SEE-THIS\Z/, 'gzip - DATA');
646
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 # simple proxy cache test
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1114
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1115 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1116 $sid = new_stream($sess, { path => '/proxy2/t2.html?2' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1117 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1118
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1119 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1120 is($frame->{headers}->{':status'}, '200', 'proxy cache');
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 my $etag = $frame->{headers}->{'etag'};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1123
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1124 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1125 is($frame->{length}, length 'SEE-THIS', 'proxy cache - DATA');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1126 is($frame->{data}, 'SEE-THIS', 'proxy cache - DATA payload');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1127
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1128 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1129 { name => ':method', value => 'GET', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1130 { name => ':scheme', value => 'http', mode => 0 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1131 { 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
1132 { name => ':authority', value => 'localhost', mode => 1 },
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1133 { name => 'if-none-match', value => $etag }]});
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1134 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1135
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1136 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1137 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
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 # HEADERS could be received with fin, followed by DATA
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1140
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1141 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1142 $sid = new_stream($sess, { path => '/proxy2/t2.html', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1143
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1144 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1145 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1146 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body');
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 # HEAD on empty cache with proxy_buffering off
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1149
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1150 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1151 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1152 { path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1153
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1154 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1155 push @$frames, $_ for @{h2_read($sess, all => [{ sid => $sid }])};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1156 ok(!grep ({ $_->{type} eq "DATA" } @$frames),
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1157 'proxy cache HEAD buffering off - no body');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1158
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1159 # request body (uses proxied response)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1160
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1161 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1162 $sid = new_stream($sess, { path => '/proxy2/t2.html', body => 'TEST' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1163 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1166 is($frame->{headers}->{'x-body'}, 'TEST', 'request body');
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 # request body with padding (uses proxied response)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1169
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1170 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1171 $sid = new_stream($sess,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1172 { path => '/proxy2/t2.html', body => 'TEST', body_padding => 42 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1173 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1174
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1175 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1176 is($frame->{headers}->{'x-body'}, 'TEST', 'request body with padding');
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 $sid = new_stream($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1179 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1180
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1181 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1182 is($frame->{headers}->{':status'}, '200', 'request body with padding - next');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1183
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1184 # initial window size, client side
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1185
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1186 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1187 # When an HTTP/2 connection is first established, new streams are
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1188 # 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
1189 # The connection flow-control window is also 65,535 octets.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1190
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1191 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1192 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1193 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1194
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1195 # 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
1196
651
9f66f0029dca Tests: HTTP/2 tests for http2_chunk_size directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 650
diff changeset
1197 @data = grep { $_->{type} eq "DATA" } @$frames;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1198 my $lengths = join ' ', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1199 is($lengths, '8192 8192 8192 8192 8192 8192 8192 8191',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1200 'iws - stream blocked on initial window size');
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 h2_ping($sess, 'SEE-THIS');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1203 $frames = h2_read($sess, all => [{ type => 'PING' }]);
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 "PING" && $_->{flags} & 0x1 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1206 ok($frame, 'iws - PING not blocked');
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 h2_window($sess, 2**16, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1209 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1210 is(@$frames, 0, 'iws - updated stream window');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1211
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1212 h2_window($sess, 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1213 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1216 my $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1217 is($sum, 81, 'iws - updated connection window');
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 # SETTINGS (initial window size, client side)
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1220
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1221 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1222 # 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
1223 # including a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1224 # frame that forms part of the connection preface. The connection
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1225 # flow-control window can only be changed using WINDOW_UPDATE frames.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1226
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1227 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1228 h2_settings($sess, 0, 0x4 => 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1229 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1230
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1231 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1232 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1233
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1234 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1235 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1236 is($sum, 2**16 + 80, 'iws - increased');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1237
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1238 # probe for negative available space in a flow control window
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1239
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1240 # 6.9.2. Initial Flow-Control Window Size
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1241 # A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1242 # 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
1243 # 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
1244 # controlled frames until it receives WINDOW_UPDATE frames that cause
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1245 # the flow-control window to become positive.
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1246
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1247 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1248 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1249 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1250
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1251 h2_window($sess, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1252 h2_settings($sess, 0, 0x4 => 42);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1253 h2_window($sess, 1024, $sid);
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 $frames = h2_read($sess, all => [{ type => 'SETTINGS' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1256
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1257 ($frame) = grep { $_->{type} eq 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1258 ok($frame, 'negative window - SETTINGS frame ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1259 is($frame->{flags}, 1, 'negative window - SETTINGS flags ack');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1260
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1261 ($frame) = grep { $_->{type} ne 'SETTINGS' } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1262 is($frame, undef, 'negative window - no data');
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 # predefined window size, minus new iws settings, minus window update
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1265
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1266 h2_window($sess, 2**16 - 1 - 42 - 1024, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1267
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1268 $frames = h2_read($sess);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1269 is(@$frames, 0, 'zero window - no data');
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 h2_window($sess, 1, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1272
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1273 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1274 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
1275
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1276 SKIP: {
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1277 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
1278
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1279 is(@$frames[0]->{type}, 'DATA', 'positive window - data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1280 is(@$frames[0]->{length}, 1, 'positive window - data length');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1281
712
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1282 }
649af6069976 Tests: skipped some HTTP/2 tests is case of a failed connection.
Sergey Kandaurov <pluknet@nginx.com>
parents: 707
diff changeset
1283
704
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1284 # 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
1285
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1286 $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
1287
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1288 h2_window($sess, 2**30, $sid);
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1289 h2_window($sess, 2**30);
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1290
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1291 sleep 1;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1292 $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
1293
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1294 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1295 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
1296
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1297 @data = grep { $_->{type} eq "DATA" } @$frames;
626bc3a0fdaa Tests: SPDY and HTTP/2 write handler tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 702
diff changeset
1298 $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
1299 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
1300
680
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1301 # SETTINGS_MAX_FRAME_SIZE
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1302
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1303 $sess = new_session();
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1304 $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
1305 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
1306 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
1307
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1308 $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
1309 @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
1310 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
1311
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1312 $sess = new_session();
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1313 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
1314 $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
1315 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
1316 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
1317
85e368105c8b Tests: added HTTP/2 tests for SETTINGS_MAX_FRAME_SIZE.
Sergey Kandaurov <pluknet@nginx.com>
parents: 679
diff changeset
1318 $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
1319 @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
1320 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
1321
696
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1322 # CONTINUATION in response
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1323 # 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
1324 # 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
1325
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1326 $sess = new_session();
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1327 $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
1328
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1329 $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
1330 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1331 is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1332 'response CONTINUATION - headers');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1333 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
1334 'response CONTINUATION - header 1');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1335 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
1336 'response CONTINUATION - header 2');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1337 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
1338 'response CONTINUATION - header 3');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1339 @data = sort { $a <=> $b } map { $_->{length} } @data;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1340 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
1341
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1342 # 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
1343
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1344 $sess = new_session();
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1345 $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
1346
beab9da9b731 Tests: added HTTP/2 tests for CONTINUATION frame in response.
Sergey Kandaurov <pluknet@nginx.com>
parents: 694
diff changeset
1347 $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
1348 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1349 is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1350 'no body CONTINUATION - headers');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1351 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
1352 'no body CONTINUATION - header 1');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1353 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
1354 'no body CONTINUATION - header 2');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1355 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
1356 'no body CONTINUATION - header 3');
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1357 @data = sort { $a <=> $b } map { $_->{length} } @data;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
1358 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
1359
698
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1360 # 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
1361
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1362 TODO: {
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1363 local $TODO = 'not yet';
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1364
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1365 $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
1366 $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
1367
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1368 $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
1369 @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
1370 @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
1371 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
1372
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1373 }
f86c8314d205 Tests: one more HTTP/2 test for max frame size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 697
diff changeset
1374
684
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1375 # 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
1376
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1377 $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
1378 $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
1379 { 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
1380 { 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
1381 { 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
1382 { 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
1383 { 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
1384 $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
1385
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1386 ($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
1387 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
1388
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1389 $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
1390 { 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
1391 { 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
1392 { 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
1393 { 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
1394 { 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
1395 $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
1396
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1397 ($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
1398 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
1399
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1400 $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
1401 $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
1402 { 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
1403 { 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
1404 { 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
1405 { 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
1406 { 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
1407 $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
1408
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1409 ($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
1410 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
1411
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1412 $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
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 . '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
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 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
1423
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1424 # 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
1425
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1426 $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
1427 $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
1428 { 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
1429 { 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
1430 { 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
1431 { 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
1432 { 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
1433 $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
1434
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1435 ($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
1436 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
1437
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1438 $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
1439 { 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
1440 { 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
1441 { 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
1442 { 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
1443 { 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
1444 $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
1445
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1446 ($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
1447 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
1448
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1449 $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
1450 $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
1451 { 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
1452 { 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
1453 { 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
1454 { 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
1455 { 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
1456 $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
1457
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1458 ($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
1459 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
1460
96666f621dbc Tests: added http2_max_field_size and http2_max_header_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 680
diff changeset
1461 $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
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 => '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
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 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
1472
722
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1473 # 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
1474 # 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
1475
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1476 $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
1477 $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
1478 { 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
1479 { 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
1480 { 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
1481 { 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
1482 { 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
1483 $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
1484
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1485 ($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
1486 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
1487
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1488 $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
1489 { 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
1490 { 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
1491 { 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
1492 { 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
1493 { 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
1494 $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
1495
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1496 ($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
1497 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
1498
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1499 $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
1500 { 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
1501 { 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
1502 { 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
1503 { 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
1504 { 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
1505 { 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
1506 $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
1507
e09a6cda6764 Tests: added HTTP/2 max_header_size tests for indexed header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 721
diff changeset
1508 ($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
1509 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
1510
736
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1511 # HPACK table boundary
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1512
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1513 $sess = new_session();
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1514 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
1515 { 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
1516 { 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
1517 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1518 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1519 { 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
1520 $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
1521 { 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
1522 { 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
1523 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1524 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1525 { 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
1526
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1527 ($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
1528 ok($frame, 'HPACK table boundary');
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1529
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1530 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
1531 { 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
1532 { 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
1533 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1534 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1535 { 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
1536 $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
1537 { 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
1538 { 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
1539 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1540 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1541 { 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
1542
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1543 ($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
1544 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
1545
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1546 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
1547 { 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
1548 { 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
1549 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1550 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1551 { 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
1552 $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
1553 { 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
1554 { 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
1555 { name => ':path', value => '/', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1556 { name => ':authority', value => '', mode => 0 },
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1557 { 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
1558
dcbe4c3d6871 Tests: added HTTP/2 tests for HPACK table boundary.
Sergey Kandaurov <pluknet@nginx.com>
parents: 735
diff changeset
1559 ($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
1560 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
1561
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1562 # stream multiplexing + WINDOW_UPDATE
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1563
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1564 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1565 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1566 $frames = h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1567
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1568 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1569 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1570 is($sum, 2**16 - 1, 'multiple - stream1 data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1571
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1572 my $sid2 = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1573 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1574
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1575 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1576 is(@data, 0, 'multiple - stream2 no data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1577
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1578 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1579 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1580 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1581
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1582 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1583 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1584 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1585 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1586
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1587 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1588 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1589 is($sum, 81, 'multiple - stream1 remain data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1590
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1591 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1592 $sum = eval join '+', map { $_->{length} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1593 is($sum, 2**16 + 80, 'multiple - stream2 full data');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1594
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1595 # stream muliplexing + PRIORITY frames
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1596
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1597 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1598 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1599 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1600
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1601 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1602 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1603
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1604 h2_priority($sess, 0, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1605 h2_priority($sess, 255, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1606
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1607 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1608 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1609 h2_window($sess, 2**17);
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 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1612 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1613 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1614 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1615
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1616 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1617 is(join(' ', map { $_->{sid} } @data), "$sid2 $sid", 'weight - PRIORITY 1');
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 # and vice versa
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, 255, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1629 h2_priority($sess, 0, $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), "$sid $sid2", 'weight - PRIORITY 2');
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 # stream muliplexing + HEADERS PRIORITY flag
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', prio => 0 });
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', prio => 255 });
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_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1653 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1654 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1655
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1656 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1657 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1658 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1659 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1660
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1661 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1662 my $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1663 is($sids, "$sid2 $sid", 'weight - HEADERS PRIORITY 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1664
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1665 # and vice versa
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1668 $sid = new_stream($sess, { path => '/t1.html', prio => 255 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1669 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1670
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1671 $sid2 = new_stream($sess, { path => '/t2.html', prio => 0 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1672 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1673
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1674 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1675 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1676 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1677
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1678 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1679 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1680 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1681 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1682
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1683 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1684 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1685 is($sids, "$sid $sid2", 'weight - HEADERS PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1686
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1687 # 5.3.1. Stream Dependencies
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 # PRIORITY frame
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1693 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1694 h2_priority($sess, 16, 1, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1695
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1696 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1697 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1698
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1699 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1700 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
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 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1703 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1704 h2_window($sess, 2**17);
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 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1707 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1708 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1709 ]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1712 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1713 is($sids, "$sid2 $sid", 'dependency - PRIORITY 1');
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 # and vice versa
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1718
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1719 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1720 h2_priority($sess, 16, 3, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1721
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1722 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1723 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1724
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1725 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1726 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1727
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1728 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1729 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1730 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1731
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1732 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1733 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1734 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1735 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1736
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1737 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1738 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1739 is($sids, "$sid $sid2", 'dependency - PRIORITY 2');
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 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1744
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1745 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1746 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1747
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1748 $sid = new_stream($sess, { path => '/t1.html', dep => 3 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1749 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1750
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1751 $sid2 = new_stream($sess, { path => '/t2.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1752 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1753
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1754 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1755 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1756 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1757
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1758 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1759 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1760 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1761 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1762
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1763 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1764 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1765 is($sids, "$sid2 $sid", 'dependency - HEADERS PRIORITY 1');
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 # and vice versa
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1770
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1771 h2_priority($sess, 16, 1, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1772 h2_priority($sess, 16, 3, 0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1773
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1774 $sid = new_stream($sess, { path => '/t1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1775 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1776
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1777 $sid2 = new_stream($sess, { path => '/t2.html', dep => 1 });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1778 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1779
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1780 h2_window($sess, 2**17, $sid);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1781 h2_window($sess, 2**17, $sid2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1782 h2_window($sess, 2**17);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1783
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1784 $frames = h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1785 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1786 { sid => $sid2, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1787 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1788
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1789 @data = grep { $_->{type} eq "DATA" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1790 $sids = join ' ', map { $_->{sid} } @data;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1791 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1792
662
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1793 # PRIORITY frame, weighted dependencies
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1794
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1795 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1796
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1797 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1798 h2_priority($sess, 255, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1799 h2_priority($sess, 0, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1800
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1801 $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
1802 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
1803
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1804 $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
1805 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
1806
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1807 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
1808 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
1809
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1810 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1811 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1812 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1813 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1814
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1815 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1816 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1817 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1818 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1819 ]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1822 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1823 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
1824
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1825 # and vice versa
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1826
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1827 $sess = new_session();
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1828
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1829 h2_priority($sess, 16, 5, 0);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1830 h2_priority($sess, 0, 1, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1831 h2_priority($sess, 255, 3, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1832
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1833 $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
1834 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
1835
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1836 $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
1837 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
1838
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1839 $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
1840 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
1841
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1842 h2_window($sess, 2**16, 1);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1843 h2_window($sess, 2**16, 3);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1844 h2_window($sess, 2**16, 5);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1845 h2_window($sess, 2**16);
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1846
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1847 $frames = h2_read($sess, all => [
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1848 { sid => $sid, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1849 { sid => $sid2, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1850 { sid => $sid3, fin => 1 },
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1851 ]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1854 $sids = join ' ', map { $_->{sid} } @data;
07de3d202eb7 Tests: more HTTP/2 tests for streams priority.
Sergey Kandaurov <pluknet@nginx.com>
parents: 661
diff changeset
1855 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
1856
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1857 # limit_conn
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1858
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1859 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1860 h2_settings($sess, 0, 0x4 => 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1861
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1862 $sid = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1863 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1864
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1865 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1866 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1867
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1868 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1869 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1870
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1871 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1872 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1873
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1874 h2_settings($sess, 0, 0x4 => 2**16);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1875
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1876 h2_read($sess, all => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1877 { sid => $sid, fin => 1 },
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1878 { sid => $sid2, fin => 1 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1879 ]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1880
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1881 # limit_conn + client's RST_STREAM
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 h2_rst($sess, $sid, 5);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1889
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1890 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1891 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1892
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1893 $sid2 = new_stream($sess, { path => '/t3.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1894 $frames = h2_read($sess, all => [{ sid => $sid2, fin => 0 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1895
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1896 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1897 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1898
654
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1899 # http2_max_concurrent_streams
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1900
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1901 $sess = new_session(8086);
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1902 $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
1903
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1904 ($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
1905 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
1906
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1907 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
1908
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1909 $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
1910 $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
1911
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1912 ($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
1913 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
1914
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1915 $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
1916 $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
1917
a64fe1054fb4 Tests: HTTP/2 tests for http2_max_concurrent_streams directive.
Sergey Kandaurov <pluknet@nginx.com>
parents: 653
diff changeset
1918 ($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
1919 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
1920
667
0247e314e991 Tests: more HTTP/2 error handling tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 662
diff changeset
1921 ($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
1922 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
1923 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
1924 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
1925 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
1926
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1927 # 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
1928
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1929 $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
1930 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1931 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1932 { 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
1933 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1934 { 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
1935 $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
1936
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1937 # 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
1938
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1939 $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
1940 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1941 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1942 { 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
1943 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1944 { 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
1945 $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
1946
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1947 # 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
1948
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1949 $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
1950 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1951 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1952 { 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
1953 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1954 { 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
1955 $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
1956
661
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1957 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
1958 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
1959
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1960 $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
1961 { name => ':method', value => 'GET' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1962 { name => ':scheme', value => 'http' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1963 { 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
1964 { name => ':authority', value => 'localhost' },
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
1965 # 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
1966 { 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
1967 { 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
1968 { 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
1969 $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
1970
c99c30afc1c9 Tests: one more test for http2_max_concurrent_streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 660
diff changeset
1971 ($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
1972 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
1973
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1974
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1975 # some invalid cases below
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1976
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1977 # invalid connection preface
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1978
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1979 $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
1980 $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
1981 $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
1982
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1983 ($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
1984 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
1985 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
1986
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1987 $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
1988 $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
1989 $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
1990
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
1991 ($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
1992 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
1993 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
1994
727
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
1995 # invalid PROXY protocol string
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
1996
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
1997 $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
1998 $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
1999 $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
2000
3e034902ebe7 Tests: added HTTP/2 test with invalid PROXY protocol string.
Sergey Kandaurov <pluknet@nginx.com>
parents: 724
diff changeset
2001 ($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
2002 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
2003 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
2004
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2005 # 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
2006 #
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2007 # 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
2008 # 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
2009 # 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
2010
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2011 $sess = new_session();
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2012 $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
2013 { 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
2014 { 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
2015 { 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
2016 { 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
2017 { 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
2018 $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
2019
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2020 # 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
2021 # 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
2022 # 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
2023
675
42de9efd11ee Tests: added HTTP/2 test for request header with newline.
Sergey Kandaurov <pluknet@nginx.com>
parents: 673
diff changeset
2024 ($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
2025 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
2026
677
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2027 # 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
2028 # 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
2029 # 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
2030
5d258aa5ebc5 Tests: more HTTP/2 tests for newline in request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 675
diff changeset
2031 ($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
2032 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
2033 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
2034 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
2035 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
2036
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2037 # GOAWAY on SYN_STREAM with even StreamID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2038
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2039 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2040 new_stream($sess, { path => '/' }, 2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2041 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2042
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2043 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2044 ok($frame, 'even stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2045 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
2046 is($frame->{last_sid}, 0, 'even stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2047
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2048 # GOAWAY on SYN_STREAM with backward StreamID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2049
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2050 # 5.1.1. Stream Identifiers
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2051 # 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
2052 # 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
2053
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2054 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2055 $sid = new_stream($sess, { path => '/' }, 3);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2056 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2057
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2058 $sid2 = new_stream($sess, { path => '/' }, 1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2059 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2060
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2061 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2062 ok($frame, 'backward stream - GOAWAY frame');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2063 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
2064 is($frame->{last_sid}, $sid, 'backward stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2065
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2066 # GOAWAY on the second SYN_STREAM with same StreamID
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2067
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2068 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2069 $sid = new_stream($sess, { path => '/' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2070 h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 $sid2 = new_stream($sess, { path => '/' }, $sid);
669
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2073 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2074
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2075 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
0c442e551ba1 Tests: corrected HTTP/2 tests for GOAWAY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 668
diff changeset
2076 ok($frame, 'dup stream - GOAWAY frame');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2077 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
2078 is($frame->{last_sid}, $sid, 'dup stream - last stream');
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2079
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2080 # missing mandatory request header ':scheme'
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 TODO: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2083 local $TODO = 'not yet';
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 $sess = new_session();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2086 $sid = new_stream($sess, { headers => [
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2087 { 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
2088 { 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
2089 { name => ':authority', value => 'localhost', mode => 1 }]});
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2090 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2093 is($frame->{headers}->{':status'}, 400, 'incomplete headers');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2094
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
673
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2097 # empty request header ':authority'
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2098
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2099 $sess = new_session();
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2100 $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
2101 { 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
2102 { 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
2103 { 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
2104 { 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
2105 $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
2106
9d6c865c2869 Tests: HTTP/2 regression test for empty authority request header.
Sergey Kandaurov <pluknet@nginx.com>
parents: 672
diff changeset
2107 ($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
2108 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
2109
697
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2110 # unknown frame type
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2111
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2112 $sess = new_session();
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2113 h2_unknown($sess, 'payload');
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2114 h2_ping($sess, 'SEE-THIS');
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2115 $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
2116
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2117 ($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
2118 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
2119
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2120 # GOAWAY - force closing a connection by server
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2121
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2122 $sid = new_stream($sess, { path => 't1.html' });
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2123 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2124
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2125 $t->stop();
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2126
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2127 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2128
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2129 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2130 ok($frame, 'GOAWAY on connection close');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2131
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2132 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2133
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2134 sub h2_ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2135 my ($sess, $payload) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2136
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2137 raw_write($sess->{socket}, pack("x2C2x5a8", 8, 0x6, $payload));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2138 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2139
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2140 sub h2_rst {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2141 my ($sess, $stream, $error) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2142
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2143 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2144 }
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 sub h2_priority {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2147 my ($sess, $w, $stream, $dep) = @_;
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 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2150 $dep = 0 unless defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2151 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w));
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2154 sub h2_window {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2155 my ($sess, $win, $stream) = @_;
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 $stream = 0 unless defined $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2158 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x8, $stream, $win));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2159 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2160
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2161 sub h2_settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2162 my ($sess, $ack, %extra) = @_;
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 my $len = 6 * keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2165 my $buf = pack_length($len) . pack "CCx4", 0x4, $ack ? 0x1 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2166 $buf .= join '', map { pack "nN", $_, $extra{$_} } keys %extra;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2167 raw_write($sess->{socket}, $buf);
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
697
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2170 sub h2_unknown {
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2171 my ($sess, $payload) = @_;
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2172
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2173 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
2174 raw_write($sess->{socket}, $buf);
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2175 }
46f698a7e59c Tests: added HTTP/2 test for unknown frame type.
Sergey Kandaurov <pluknet@nginx.com>
parents: 696
diff changeset
2176
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2177 sub h2_continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2178 my ($ctx, $stream, $uri) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2179
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2180 $uri->{h2_continue} = 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2181 return new_stream($ctx, $uri, $stream);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2182 }
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 sub new_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2185 my ($ctx, $uri, $stream) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2186 my ($input, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2187 my ($d, $status);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2188
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2189 $ctx->{headers} = '';
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2190
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2191 my $host = $uri->{host} || '127.0.0.1:8080';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2192 my $method = $uri->{method} || 'GET';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2193 my $scheme = $uri->{scheme} || 'http';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2194 my $path = $uri->{path} || '/';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2195 my $headers = $uri->{headers};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2196 my $body = $uri->{body};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2197 my $prio = $uri->{prio};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2198 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
2199 my $split = ref $uri->{continuation} && $uri->{continuation} || [];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2200
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2201 my $pad = defined $uri->{padding} ? $uri->{padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2202 my $padlen = defined $uri->{padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2203 my $bpad = defined $uri->{body_padding} ? $uri->{body_padding} : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2204 my $bpadlen = defined $uri->{body_padding} ? 1 : 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2205
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2206 my $type = defined $uri->{h2_continue} ? 0x9 : 0x1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2207 my $flags = defined $uri->{continuation} ? 0x0 : 0x4;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2208 $flags |= 0x1 unless defined $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2209 $flags |= 0x8 if $padlen;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2210 $flags |= 0x20 if defined $dep || defined $prio;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2211
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2212 if ($stream) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2213 $ctx->{last_stream} = $stream;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2214 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2215 $ctx->{last_stream} += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2216 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2217
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2218 $buf = pack("xxx"); # Length stub
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2219 $buf .= pack("CC", $type, $flags); # END_HEADERS
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2220 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2221
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2222 $dep = 0 if defined $prio and not defined $dep;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2223 $prio = 16 if defined $dep and not defined $prio;
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 unless ($headers) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2226 $input = hpack($ctx, ":method", $method);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2227 $input .= hpack($ctx, ":scheme", $scheme);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2228 $input .= hpack($ctx, ":path", $path);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2229 $input .= hpack($ctx, ":authority", $host);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2230 $input .= hpack($ctx, "content-length", length($body)) if $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2231
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2232 } else {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2233 $input = join '', map {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2234 hpack($ctx, $_->{name}, $_->{value},
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2235 mode => $_->{mode}, huff => $_->{huff})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2236 } @$headers if $headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2237 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2238
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2239 $input = pack("B*", '001' . ipack(5, $uri->{table_size})) . $input
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2240 if defined $uri->{table_size};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2241
702
cc2b98d028c8 Tests: fixed HTTP/2 test for CONTINUATION while in header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 700
diff changeset
2242 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
2243 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
2244
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2245 # set length, attach headers, padding, priority
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2246
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2247 my $hlen = length($input[0]) + $pad + $padlen;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2248 $hlen += 5 if $flags & 0x20;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2249 $buf |= pack_length($hlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2250
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2251 $buf .= pack 'C', $pad if $padlen; # Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2252 $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
2253 $buf .= $input[0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2254 $buf .= (pack 'C', 0) x $pad if $padlen; # Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2255
699
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2256 shift @input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2257
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2258 while (@input) {
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2259 $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
2260 $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
2261 $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
2262 $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
2263 $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
2264 $buf .= $input;
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2265 }
5768830f01c4 Tests: HTTP/2 test for CONTINUATION in the middle of header field.
Sergey Kandaurov <pluknet@nginx.com>
parents: 698
diff changeset
2266
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2267 if (defined $body) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2268 $buf .= pack_length(length($body) + $bpad + $bpadlen);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2269 my $flags = $bpadlen ? 0x8 : 0x0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2270 $buf .= pack 'CC', 0x0, 0x1 | $flags; # DATA, END_STREAM
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2271 $buf .= pack 'N', $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2272 $buf .= pack 'C', $bpad if $bpadlen; # DATA Pad Length?
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2273 $buf .= $body;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2274 $buf .= (pack 'C', 0) x $bpad if $bpadlen; # DATA Padding
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2275 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2276
715
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2277 $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
2278 for (@$split) {
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2279 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
2280 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
2281 }
9ee52e137f3d Tests: more HTTP/2 HPACK decoding tests with discarded streams.
Sergey Kandaurov <pluknet@nginx.com>
parents: 714
diff changeset
2282
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2283 raw_write($ctx->{socket}, $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2284 return $ctx->{last_stream};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2285 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2286
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2287 sub h2_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2288 my ($sess, %extra) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2289 my (@got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2290 my $s = $sess->{socket};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2291 my $buf = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2292
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2293 while (1) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2294 $buf = raw_read($s, $buf, 9);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2295 last unless length $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2296
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2297 my $length = unpack_length($buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2298 my $type = unpack('x3C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2299 my $flags = unpack('x4C', $buf);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2300
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2301 my $stream = unpack "x5 B32", $buf;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2302 substr($stream, 0, 1) = 0;
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2303 $stream = unpack("N", pack("B32", $stream));
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2304
679
b60c1a207675 Tests: fixed HTTP/2 tests with large frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 677
diff changeset
2305 $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
2306 last if length($buf) < $length + 9;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2307
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2308 $buf = substr($buf, 9);
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2309
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2310 my $frame = $cframe{$type}{value}($sess, $buf, $length, $flags);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2311 $frame->{length} = $length;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2312 $frame->{type} = $cframe{$type}{name};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2313 $frame->{flags} = $flags;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2314 $frame->{sid} = $stream;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2315 push @got, $frame;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2316
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2317 $buf = substr($buf, $length);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2318
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2319 last unless test_fin($got[-1], $extra{all});
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 return \@got;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2322 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2323
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2324 sub test_fin {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2325 my ($frame, $all) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2326 my @test = @{$all};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2327
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2328 # wait for the specified DATA length
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2329
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2330 for (@test) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2331 if ($_->{length} && $frame->{type} eq 'DATA') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2332 # check also for StreamID if needed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2333
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2334 if (!$_->{sid} || $_->{sid} == $frame->{sid}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2335 $_->{length} -= $frame->{length};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2336 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2337 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2338 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2339 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2340
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2341 # wait for the fin flag
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 @test = grep { !(defined $_->{fin}
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2344 && $_->{sid} == $frame->{sid} && $_->{fin} & $frame->{flags})
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2345 } @test if defined $frame->{flags};
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 # wait for the specified frame
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2348
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2349 @test = grep { !($_->{type} && $_->{type} eq $frame->{type}) } @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2350
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2351 @{$all} = @test;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2352 }
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 sub headers {
718
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2355 my ($ctx, $buf, $len, $flags) = @_;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2356 $ctx->{headers} .= substr($buf, 0, $len);
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2357 return unless $flags & 0x4;
ba822b2e899c Tests: rewrote HTTP/2 response CONTINUATION tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
2358 { headers => hunpack($ctx, $ctx->{headers}, length($ctx->{headers})) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2359 }
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 sub data {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2362 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2363 return { data => substr($buf, 0, $len) };
646
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2366 sub settings {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2367 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2368 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2369 my $skip = 0;
646
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 for (1 .. $len / 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2372 my $id = hex unpack "\@$skip n", $buf; $skip += 2;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2373 $payload{$id} = unpack "\@$skip N", $buf; $skip += 4;
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 return \%payload;
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 ping {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2379 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
2380 return { value => unpack "A$len", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2381 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2382
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2383 sub rst_stream {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2384 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2385 return { code => unpack "N", $buf };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2386 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2387
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2388 sub goaway {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2389 my ($ctx, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2390 my %payload;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2391
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2392 my $stream = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2393 substr($stream, 0, 1) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2394 $stream = unpack("N", pack("B32", $stream));
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2395 $payload{last_sid} = $stream;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2396
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2397 $len -= 4;
670
944b87756cab Tests: fixed GOAWAY and PING frames parsing in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 669
diff changeset
2398 $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
2399 $payload{debug} = unpack "x8 A$len", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2400 return \%payload;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2403 sub window_update {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2404 my ($ctx, $buf, $len) = @_;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2405 my $value = unpack "B32", $buf;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2406 substr($value, 0, 1) = 0;
655
75ecd26b8831 Tests: HTTP/2 tests cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 654
diff changeset
2407 return { wdelta => unpack("N", pack("B32", $value)) };
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2408 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2409
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2410 sub pack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2411 pack 'c3', unpack 'xc3', pack 'N', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2412 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2413
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2414 sub unpack_length {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2415 unpack 'N', pack 'xc3', unpack 'c3', $_[0];
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2416 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2417
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2418 sub raw_read {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2419 my ($s, $buf, $len) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2420 my $got = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2421
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2422 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
2423 $s->sysread($got, 16384) or last;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2424 log_in($got);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2425 $buf .= $got;
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 return $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2428 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2429
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2430 sub raw_write {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2431 my ($s, $message) = @_;
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 local $SIG{PIPE} = 'IGNORE';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2434
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2435 while (IO::Select->new($s)->can_write(0.4)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2436 log_out($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2437 my $n = $s->syswrite($message);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2438 last unless $n;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2439 $message = substr($message, $n);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2440 last unless length $message;
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 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2443
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2444 sub new_session {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2445 my ($port, %extra) = @_;
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2446
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2447 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
2448 my $preface = $extra{preface}
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2449 || 'PRI * HTTP/2.0' . CRLF . CRLF . 'SM' . CRLF . CRLF;
646
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 if ($extra{proxy}) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2452 raw_write($s, $extra{proxy});
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2455 # preface
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2456
728
61800918f647 Tests: added HTTP/2 tests with invalid connection preface.
Sergey Kandaurov <pluknet@nginx.com>
parents: 727
diff changeset
2457 raw_write($s, $preface);
646
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 return { socket => $s, last_stream => -1,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2460 dynamic_encode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2461 dynamic_decode => [ static_table() ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2462 static_table_size => scalar @{[static_table()]} };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2463 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2464
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2465 sub new_socket {
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2466 my ($port, %extra) = @_;
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2467 my $npn = $extra{'npn'};
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2468 my $alpn = $extra{'alpn'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2469 my $s;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2470
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2471 $port = 8080 unless defined $port;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2472
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2473 eval {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2474 local $SIG{ALRM} = sub { die "timeout\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2475 local $SIG{PIPE} = sub { die "sigpipe\n" };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2476 alarm(2);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2477 $s = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2478 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2479 PeerAddr => "127.0.0.1:$port",
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2480 );
650
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2481 IO::Socket::SSL->start_SSL($s,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2482 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
2483 SSL_npn_protocols => $npn ? [ $npn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2484 SSL_alpn_protocols => $alpn ? [ $alpn ] : undef,
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2485 SSL_error_trap => sub { die $_[1] }
8a2cf558b8ae Tests: HTTP/2 tests for $http2 variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 647
diff changeset
2486 ) if $extra{'SSL'};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2487 alarm(0);
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 alarm(0);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2490
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2491 if ($@) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2492 log_in("died: $@");
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2493 return undef;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2496 return $s;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2497 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2498
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2499 sub static_table {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2500 [ '', '' ], # unused
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2501 [ ':authority', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2502 [ ':method', 'GET' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2503 [ ':method', 'POST' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2504 [ ':path', '/' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2505 [ ':path', '/index.html' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2506 [ ':scheme', 'http' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2507 [ ':scheme', 'https' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2508 [ ':status', '200' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2509 [ ':status', '204' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2510 [ ':status', '206' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2511 [ ':status', '304' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2512 [ ':status', '400' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2513 [ ':status', '404' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2514 [ ':status', '500' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2515 [ 'accept-charset', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2516 [ 'accept-encoding', 'gzip, deflate' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2517 [ 'accept-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2518 [ 'accept-ranges', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2519 [ 'accept', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2520 [ 'access-control-allow-origin',
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 [ 'age', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2523 [ 'allow', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2524 [ 'authorization', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2525 [ 'cache-control', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2526 [ 'content-disposition',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2527 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2528 [ 'content-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2529 [ 'content-language', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2530 [ 'content-length', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2531 [ 'content-location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2532 [ 'content-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2533 [ 'content-type', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2534 [ 'cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2535 [ 'date', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2536 [ 'etag', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2537 [ 'expect', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2538 [ 'expires', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2539 [ 'from', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2540 [ 'host', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2541 [ 'if-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2542 [ 'if-modified-since', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2543 [ 'if-none-match', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2544 [ 'if-range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2545 [ 'if-unmodified-since',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2546 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2547 [ 'last-modified', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2548 [ 'link', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2549 [ 'location', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2550 [ 'max-forwards', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2551 [ 'proxy-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2552 [ 'proxy-authorization',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2553 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2554 [ 'range', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2555 [ 'referer', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2556 [ 'refresh', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2557 [ 'retry-after', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2558 [ 'server', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2559 [ 'set-cookie', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2560 [ 'strict-transport-security',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2561 '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2562 [ 'transfer-encoding', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2563 [ 'user-agent', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2564 [ 'vary', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2565 [ 'via', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2566 [ 'www-authenticate', '' ],
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2567 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2568
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2569 # RFC 7541, 5.1. Integer Representation
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2570
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2571 sub ipack {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2572 my ($base, $d) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2573 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
2574
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2575 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
2576 $d -= 2**$base - 1;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2577 while ($d >= 128) {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2578 $o .= sprintf("%8b", $d % 128 + 128);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2579 $d /= 128;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2580 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2581 $o .= sprintf("%08b", $d);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2582 return $o;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2583 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2584
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2585 sub iunpack {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2586 my ($base, $b, $s) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2587
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2588 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
2589 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
2590 $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
2591 $len = unpack("C", pack("B8", $len));
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2592
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2593 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
2594
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2595 my $m = 0;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2596 my $d;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2597
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2598 do {
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2599 $d = unpack("\@$s C", $b); $s++;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2600 $len += ($d & 127) * 2**$m;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2601 $m += $base;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2602 } while (($d & 128) == 128);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2603
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2604 return ($len, $s, $prefix);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2605 }
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2606
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2607 sub hpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2608 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
2609 my $table = $ctx->{dynamic_encode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2610 my $mode = defined $extra{mode} ? $extra{mode} : 1;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2611 my $huff = $extra{huff};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2612
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2613 my ($index, $buf) = 0;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2614
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2615 # 6.1. Indexed Header Field Representation
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2616
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2617 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
2618 ++$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
2619 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
2620 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
2621 $buf = pack('B*', '1' . ipack(7, $index));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2622 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2623
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2624 # 6.2.1. Literal Header Field with Incremental Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2625
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2626 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
2627 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
2628
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2629 ++$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
2630 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2631 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2632
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2633 $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
2634 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2635 $buf .= $value;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2638 # 6.2.1. Literal Header Field with Incremental Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2639
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2640 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
2641 splice @$table, $ctx->{static_table_size}, 0, [ $name, $value ];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2642
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2643 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2644 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2645 my $hbit = ($huff ? '1' : '0');
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 $buf = pack('B*', '01000000');
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2648 $buf .= pack('B*', $hbit . ipack(7, length($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2649 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2650 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2651 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2652 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2653
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2654 # 6.2.2. Literal Header Field without Indexing
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2655
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2656 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
2657 ++$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
2658 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2659 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2660
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2661 $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
2662 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2663 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2664 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2665
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2666 # 6.2.2. Literal Header Field without Indexing -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2667
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2668 if ($mode == 4) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2669 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2670 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2671 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2672
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2673 $buf = pack('B*', '00000000');
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($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2675 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2676 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2677 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2678 }
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 # 6.2.3. Literal Header Field Never Indexed
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2681
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2682 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
2683 ++$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
2684 or $table->[$index][0] eq $name;
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2685 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2686
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2687 $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
2688 . ($huff ? '1' : '0') . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2689 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2690 }
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 # 6.2.3. Literal Header Field Never Indexed -- New Name
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2693
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2694 if ($mode == 6) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2695 my $name = $huff ? huff($name) : $name;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2696 my $value = $huff ? huff($value) : $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2697 my $hbit = ($huff ? '1' : '0');
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2698
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2699 $buf = pack('B*', '00010000');
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($name)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2701 $buf .= $name;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2702 $buf .= pack('B*', $hbit . ipack(7, length($value)));
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2703 $buf .= $value;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2704 }
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 return $buf;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2707 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2708
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2709 sub hunpack {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2710 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
2711 my $table = $ctx->{dynamic_decode};
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2712 my %headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2713 my $skip = 0;
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2714 my ($index, $name, $value);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2715
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2716 my $field = sub {
694
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2717 my ($b) = @_;
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2718 my ($len, $s, $huff) = iunpack(7, @_);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2719
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2720 my $field = substr($b, $s, $len);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2721 $field = $huff ? dehuff($field) : $field;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2722 $s += $len;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2723 return ($field, $s);
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2724 };
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2725
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2726 my $add = sub {
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2727 my ($h, $n, $v) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2728 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
2729 $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
2730 push @{$h->{$n}}, $v;
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2731 };
646
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 while ($skip < $length) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2734 my $ib = unpack("\@$skip B8", $data);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2735
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2736 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
2737 ($index, $skip) = iunpack(7, $data, $skip);
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2738 $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
2739 $table->[$index][0], $table->[$index][1]);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2740 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2741 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2742
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2743 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
2744 ($index, $skip) = iunpack(6, $data, $skip);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2745 $name = $table->[$index][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2746
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2747 ($name, $skip) = $field->($data, $skip) unless $name;
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2748 ($value, $skip) = $field->($data, $skip);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2749
671
0c70eb166a3a Tests: in HTTP/2 tests, always access a dynamic table by reference.
Sergey Kandaurov <pluknet@nginx.com>
parents: 670
diff changeset
2750 splice @$table,
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2751 $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
2752 $add->(\%headers, $name, $value);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2753 next;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2754 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2755
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2756 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
2757 ($index, $skip) = iunpack(4, $data, $skip);
3eba6e1b8313 Tests: finished HPACK coding in HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 692
diff changeset
2758 $name = $table->[$index][0];
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2759
735
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2760 ($name, $skip) = $field->($data, $skip) unless $name;
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2761 ($value, $skip) = $field->($data, $skip);
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2762
832cd7cc8f53 Tests: made h2.t inner functions anonymous.
Sergey Kandaurov <pluknet@nginx.com>
parents: 730
diff changeset
2763 $add->(\%headers, $name, $value);
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2768 return \%headers;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2769 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2770
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2771 sub huff_code { scalar {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2772 pack('C', 0) => '1111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2773 pack('C', 1) => '11111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2774 pack('C', 2) => '1111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2775 pack('C', 3) => '1111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2776 pack('C', 4) => '1111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2777 pack('C', 5) => '1111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2778 pack('C', 6) => '1111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2779 pack('C', 7) => '1111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2780 pack('C', 8) => '1111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2781 pack('C', 9) => '111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2782 pack('C', 10) => '111111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2783 pack('C', 11) => '1111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2784 pack('C', 12) => '1111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2785 pack('C', 13) => '111111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2786 pack('C', 14) => '1111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2787 pack('C', 15) => '1111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2788 pack('C', 16) => '1111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2789 pack('C', 17) => '1111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2790 pack('C', 18) => '1111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2791 pack('C', 19) => '1111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2792 pack('C', 20) => '1111111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2793 pack('C', 21) => '1111111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2794 pack('C', 22) => '111111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2795 pack('C', 23) => '1111111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2796 pack('C', 24) => '1111111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2797 pack('C', 25) => '1111111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2798 pack('C', 26) => '1111111111111111111111110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2799 pack('C', 27) => '1111111111111111111111110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2800 pack('C', 28) => '1111111111111111111111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2801 pack('C', 29) => '1111111111111111111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2802 pack('C', 30) => '1111111111111111111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2803 pack('C', 31) => '1111111111111111111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2804 pack('C', 32) => '010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2805 pack('C', 33) => '1111111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2806 pack('C', 34) => '1111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2807 pack('C', 35) => '111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2808 pack('C', 36) => '1111111111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2809 pack('C', 37) => '010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2810 pack('C', 38) => '11111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2811 pack('C', 39) => '11111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2812 pack('C', 40) => '1111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2813 pack('C', 41) => '1111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2814 pack('C', 42) => '11111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2815 pack('C', 43) => '11111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2816 pack('C', 44) => '11111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2817 pack('C', 45) => '010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2818 pack('C', 46) => '010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2819 pack('C', 47) => '011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2820 pack('C', 48) => '00000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2821 pack('C', 49) => '00001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2822 pack('C', 50) => '00010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2823 pack('C', 51) => '011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2824 pack('C', 52) => '011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2825 pack('C', 53) => '011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2826 pack('C', 54) => '011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2827 pack('C', 55) => '011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2828 pack('C', 56) => '011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2829 pack('C', 57) => '011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2830 pack('C', 58) => '1011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2831 pack('C', 59) => '11111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2832 pack('C', 60) => '111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2833 pack('C', 61) => '100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2834 pack('C', 62) => '111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2835 pack('C', 63) => '1111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2836 pack('C', 64) => '1111111111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2837 pack('C', 65) => '100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2838 pack('C', 66) => '1011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2839 pack('C', 67) => '1011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2840 pack('C', 68) => '1011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2841 pack('C', 69) => '1100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2842 pack('C', 70) => '1100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2843 pack('C', 71) => '1100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2844 pack('C', 72) => '1100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2845 pack('C', 73) => '1100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2846 pack('C', 74) => '1100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2847 pack('C', 75) => '1100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2848 pack('C', 76) => '1100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2849 pack('C', 77) => '1101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2850 pack('C', 78) => '1101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2851 pack('C', 79) => '1101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2852 pack('C', 80) => '1101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2853 pack('C', 81) => '1101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2854 pack('C', 82) => '1101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2855 pack('C', 83) => '1101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2856 pack('C', 84) => '1101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2857 pack('C', 85) => '1110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2858 pack('C', 86) => '1110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2859 pack('C', 87) => '1110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2860 pack('C', 88) => '11111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2861 pack('C', 89) => '1110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2862 pack('C', 90) => '11111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2863 pack('C', 91) => '1111111111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2864 pack('C', 92) => '1111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2865 pack('C', 93) => '1111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2866 pack('C', 94) => '11111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2867 pack('C', 95) => '100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2868 pack('C', 96) => '111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2869 pack('C', 97) => '00011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2870 pack('C', 98) => '100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2871 pack('C', 99) => '00100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2872 pack('C', 100) => '100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2873 pack('C', 101) => '00101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2874 pack('C', 102) => '100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2875 pack('C', 103) => '100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2876 pack('C', 104) => '100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2877 pack('C', 105) => '00110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2878 pack('C', 106) => '1110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2879 pack('C', 107) => '1110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2880 pack('C', 108) => '101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2881 pack('C', 109) => '101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2882 pack('C', 110) => '101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2883 pack('C', 111) => '00111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2884 pack('C', 112) => '101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2885 pack('C', 113) => '1110110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2886 pack('C', 114) => '101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2887 pack('C', 115) => '01000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2888 pack('C', 116) => '01001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2889 pack('C', 117) => '101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2890 pack('C', 118) => '1110111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2891 pack('C', 119) => '1111000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2892 pack('C', 120) => '1111001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2893 pack('C', 121) => '1111010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2894 pack('C', 122) => '1111011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2895 pack('C', 123) => '111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2896 pack('C', 124) => '11111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2897 pack('C', 125) => '11111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2898 pack('C', 126) => '1111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2899 pack('C', 127) => '1111111111111111111111111100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2900 pack('C', 128) => '11111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2901 pack('C', 129) => '1111111111111111010010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2902 pack('C', 130) => '11111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2903 pack('C', 131) => '11111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2904 pack('C', 132) => '1111111111111111010011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2905 pack('C', 133) => '1111111111111111010100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2906 pack('C', 134) => '1111111111111111010101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2907 pack('C', 135) => '11111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2908 pack('C', 136) => '1111111111111111010110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2909 pack('C', 137) => '11111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2910 pack('C', 138) => '11111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2911 pack('C', 139) => '11111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2912 pack('C', 140) => '11111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2913 pack('C', 141) => '11111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2914 pack('C', 142) => '111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2915 pack('C', 143) => '11111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2916 pack('C', 144) => '111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2917 pack('C', 145) => '111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2918 pack('C', 146) => '1111111111111111010111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2919 pack('C', 147) => '11111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2920 pack('C', 148) => '111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2921 pack('C', 149) => '11111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2922 pack('C', 150) => '11111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2923 pack('C', 151) => '11111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2924 pack('C', 152) => '11111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2925 pack('C', 153) => '111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2926 pack('C', 154) => '1111111111111111011000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2927 pack('C', 155) => '11111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2928 pack('C', 156) => '1111111111111111011001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2929 pack('C', 157) => '11111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2930 pack('C', 158) => '11111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2931 pack('C', 159) => '111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2932 pack('C', 160) => '1111111111111111011010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2933 pack('C', 161) => '111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2934 pack('C', 162) => '11111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2935 pack('C', 163) => '1111111111111111011011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2936 pack('C', 164) => '1111111111111111011100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2937 pack('C', 165) => '11111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2938 pack('C', 166) => '11111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2939 pack('C', 167) => '111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2940 pack('C', 168) => '11111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2941 pack('C', 169) => '1111111111111111011101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2942 pack('C', 170) => '1111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2943 pack('C', 171) => '111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2944 pack('C', 172) => '111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2945 pack('C', 173) => '1111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2946 pack('C', 174) => '11111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2947 pack('C', 175) => '11111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2948 pack('C', 176) => '111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2949 pack('C', 177) => '111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2950 pack('C', 178) => '1111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2951 pack('C', 179) => '111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2952 pack('C', 180) => '11111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2953 pack('C', 181) => '1111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2954 pack('C', 182) => '11111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2955 pack('C', 183) => '11111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2956 pack('C', 184) => '11111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2957 pack('C', 185) => '1111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2958 pack('C', 186) => '1111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2959 pack('C', 187) => '1111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2960 pack('C', 188) => '11111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2961 pack('C', 189) => '1111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2962 pack('C', 190) => '1111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2963 pack('C', 191) => '11111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2964 pack('C', 192) => '11111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2965 pack('C', 193) => '11111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2966 pack('C', 194) => '11111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2967 pack('C', 195) => '1111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2968 pack('C', 196) => '1111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2969 pack('C', 197) => '11111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2970 pack('C', 198) => '1111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2971 pack('C', 199) => '1111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2972 pack('C', 200) => '11111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2973 pack('C', 201) => '11111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2974 pack('C', 202) => '11111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2975 pack('C', 203) => '111111111111111111111011110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2976 pack('C', 204) => '111111111111111111111011111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2977 pack('C', 205) => '11111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2978 pack('C', 206) => '111111111111111111110001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2979 pack('C', 207) => '1111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2980 pack('C', 208) => '1111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2981 pack('C', 209) => '111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2982 pack('C', 210) => '11111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2983 pack('C', 211) => '111111111111111111111100000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2984 pack('C', 212) => '111111111111111111111100001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2985 pack('C', 213) => '11111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2986 pack('C', 214) => '111111111111111111111100010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2987 pack('C', 215) => '111111111111111111110010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2988 pack('C', 216) => '111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2989 pack('C', 217) => '111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2990 pack('C', 218) => '11111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2991 pack('C', 219) => '11111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2992 pack('C', 220) => '1111111111111111111111111101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2993 pack('C', 221) => '111111111111111111111100011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2994 pack('C', 222) => '111111111111111111111100100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2995 pack('C', 223) => '111111111111111111111100101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2996 pack('C', 224) => '11111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2997 pack('C', 225) => '111111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2998 pack('C', 226) => '11111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2999 pack('C', 227) => '111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3000 pack('C', 228) => '1111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3001 pack('C', 229) => '111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3002 pack('C', 230) => '111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3003 pack('C', 231) => '11111111111111111110011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3004 pack('C', 232) => '1111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3005 pack('C', 233) => '1111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3006 pack('C', 234) => '1111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3007 pack('C', 235) => '1111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3008 pack('C', 236) => '111111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3009 pack('C', 237) => '111111111111111111110101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3010 pack('C', 238) => '11111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3011 pack('C', 239) => '11111111111111111110100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3012 pack('C', 240) => '11111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3013 pack('C', 241) => '111111111111111111111100110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3014 pack('C', 242) => '11111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3015 pack('C', 243) => '11111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3016 pack('C', 244) => '111111111111111111111100111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3017 pack('C', 245) => '111111111111111111111101000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3018 pack('C', 246) => '111111111111111111111101001',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3019 pack('C', 247) => '111111111111111111111101010',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3020 pack('C', 248) => '111111111111111111111101011',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3021 pack('C', 249) => '1111111111111111111111111110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3022 pack('C', 250) => '111111111111111111111101100',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3023 pack('C', 251) => '111111111111111111111101101',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3024 pack('C', 252) => '111111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3025 pack('C', 253) => '111111111111111111111101111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3026 pack('C', 254) => '111111111111111111111110000',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3027 pack('C', 255) => '11111111111111111111101110',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3028 '_eos' => '111111111111111111111111111111',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3029 }};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3030
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3031 sub huff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3032 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3033 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3034
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3035 my $ret = join '', map { $code->{$_} } (split //, $string);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3036 my $len = length($ret) + (8 - length($ret) % 8);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3037 $ret .= $code->{_eos};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3038
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3039 return pack("B$len", $ret);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3040 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3041
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3042 sub dehuff {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3043 my ($string) = @_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3044 my $code = &huff_code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3045 my %decode = reverse %$code;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3046
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3047 my $ret = ''; my $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3048 for (split //, unpack('B*', $string)) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3049 $c .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3050 next unless exists $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3051 last if $decode{$c} eq '_eos';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3052
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3053 $ret .= $decode{$c};
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3054 $c = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3055 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3056
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3057 return $ret;
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3060 ###############################################################################
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3061
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3062 sub gunzip_like {
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3063 my ($in, $re, $name) = @_;
646
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 SKIP: {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3066 eval { require IO::Uncompress::Gunzip; };
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3067 Test::More::skip(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3068 "IO::Uncompress::Gunzip not installed", 1) if $@;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3069
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3070 my $out;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3071
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3072 IO::Uncompress::Gunzip::gunzip(\$in => \$out);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3073
647
4e36550410b3 Tests: h2.t fixes for older perl versions, and gzip test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 646
diff changeset
3074 like($out, $re, $name);
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3075 }
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3078 ###############################################################################
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 # for tests with multiple header fields
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3081
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3082 sub http_daemon {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3083 my $server = IO::Socket::INET->new(
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3084 Proto => 'tcp',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3085 LocalHost => '127.0.0.1',
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3086 LocalPort => 8083,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3087 Listen => 5,
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3088 Reuse => 1
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3089 )
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3090 or die "Can't create listening socket: $!\n";
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3091
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3092 local $SIG{PIPE} = 'IGNORE';
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 while (my $client = $server->accept()) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3095 $client->autoflush(1);
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3096
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3097 my $headers = '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3098 my $uri = '';
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 while (<$client>) {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3101 $headers .= $_;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3102 last if (/^\x0d?\x0a?$/);
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
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3105 next if $headers eq '';
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3106 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3107
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3108 if ($uri eq '/cookie') {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3109
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3110 my ($cookie, $cookie2) = $headers =~ /Cookie: (.+)/ig;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3111 $cookie2 = '' unless defined $cookie2;
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3112
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3113 my ($cookie_a, $cookie_c) = ('', '');
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3114 $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
3115 $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
3116
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3117 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3118 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3119 Connection: close
652
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3120 X-Sent-Cookie: $cookie
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3121 X-Sent-Cookie2: $cookie2
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3122 X-Sent-Cookie-a: $cookie_a
5a85ad9382a3 Tests: more Cookie tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 651
diff changeset
3123 X-Sent-Cookie-c: $cookie_c
646
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3124
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3125 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3126
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3127 } elsif ($uri eq '/set-cookie') {
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 print $client <<EOF;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3130 HTTP/1.1 200 OK
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3131 Connection: close
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3132 Set-Cookie: a=b
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3133 Set-Cookie: c=d
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3134
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3135 EOF
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3136
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3137 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3138
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3139 } continue {
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3140 close $client;
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3141 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3142 }
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3143
843a74ff43bc Tests: HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3144 ###############################################################################