Mercurial > hg > nginx-tests
comparison h2.t @ 696:beab9da9b731
Tests: added HTTP/2 tests for CONTINUATION frame in response.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 15 Sep 2015 12:54:19 +0300 |
parents | 3eba6e1b8313 |
children | 46f698a7e59c |
comparison
equal
deleted
inserted
replaced
695:da20b4389038 | 696:beab9da9b731 |
---|---|
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; | 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; | 31 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
32 | 32 |
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) | 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) |
34 ->has(qw/limit_conn rewrite realip shmem/) | 34 ->has(qw/limit_conn rewrite realip shmem/) |
35 ->has_daemon('openssl')->plan(179); | 35 ->has_daemon('openssl')->plan(193); |
36 | 36 |
37 $t->write_file_expand('nginx.conf', <<'EOF'); | 37 $t->write_file_expand('nginx.conf', <<'EOF'); |
38 | 38 |
39 %%TEST_GLOBALS%% | 39 %%TEST_GLOBALS%% |
40 | 40 |
57 listen 127.0.0.1:8084 http2 ssl; | 57 listen 127.0.0.1:8084 http2 ssl; |
58 server_name localhost; | 58 server_name localhost; |
59 | 59 |
60 ssl_certificate_key localhost.key; | 60 ssl_certificate_key localhost.key; |
61 ssl_certificate localhost.crt; | 61 ssl_certificate localhost.crt; |
62 http2_max_field_size 128k; | |
62 | 63 |
63 location / { | 64 location / { |
64 add_header X-Header X-Foo; | 65 add_header X-Header X-Foo; |
65 add_header X-Sent-Foo $http_x_foo; | 66 add_header X-Sent-Foo $http_x_foo; |
66 add_header X-Referer $http_referer; | 67 add_header X-Referer $http_referer; |
78 } | 79 } |
79 location /frame_size { | 80 location /frame_size { |
80 http2_chunk_size 64k; | 81 http2_chunk_size 64k; |
81 alias %%TESTDIR%%/t1.html; | 82 alias %%TESTDIR%%/t1.html; |
82 output_buffers 2 1m; | 83 output_buffers 2 1m; |
84 } | |
85 location /continuation { | |
86 add_header X-LongHeader $arg_h; | |
87 add_header X-LongHeader $arg_h; | |
88 add_header X-LongHeader $arg_h; | |
89 return 200 body; | |
90 | |
91 location /continuation/204 { | |
92 return 204; | |
93 } | |
83 } | 94 } |
84 location /pp { | 95 location /pp { |
85 set_real_ip_from 127.0.0.1/32; | 96 set_real_ip_from 127.0.0.1/32; |
86 real_ip_header proxy_protocol; | 97 real_ip_header proxy_protocol; |
87 alias %%TESTDIR%%/t2.html; | 98 alias %%TESTDIR%%/t2.html; |
216 4 => { name => 'SETTINGS', value => \&settings }, | 227 4 => { name => 'SETTINGS', value => \&settings }, |
217 # 5 => { name => 'PUSH_PROIMSE', value => \&push_promise }, | 228 # 5 => { name => 'PUSH_PROIMSE', value => \&push_promise }, |
218 6 => { name => 'PING', value => \&ping }, | 229 6 => { name => 'PING', value => \&ping }, |
219 7 => { name => 'GOAWAY', value => \&goaway }, | 230 7 => { name => 'GOAWAY', value => \&goaway }, |
220 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, | 231 8 => { name => 'WINDOW_UPDATE', value => \&window_update }, |
221 # 9 => { name => 'CONTINUATION', value => \&continuation }, | 232 9 => { name => 'CONTINUATION', value => \&headers }, |
222 ); | 233 ); |
223 | 234 |
224 ############################################################################### | 235 ############################################################################### |
225 | 236 |
226 # SETTINGS | 237 # SETTINGS |
1086 h2_window($sess, 2**18); | 1097 h2_window($sess, 2**18); |
1087 | 1098 |
1088 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | 1099 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
1089 @data = grep { $_->{type} eq "DATA" } @$frames; | 1100 @data = grep { $_->{type} eq "DATA" } @$frames; |
1090 is($data[0]->{length}, 2**15, 'max frame size - custom'); | 1101 is($data[0]->{length}, 2**15, 'max frame size - custom'); |
1102 | |
1103 # CONTINUATION in response | |
1104 # put three long header fields (not less than SETTINGS_MAX_FRAME_SIZE/2) | |
1105 # to break header block into separate frames, one such field per frame | |
1106 | |
1107 $sess = new_session(); | |
1108 $sid = new_stream($sess, { path => '/continuation?h=' . 'x' x 2**13 }); | |
1109 | |
1110 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); | |
1111 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; | |
1112 is(@data, 3, 'response CONTINUATION - header block frames'); | |
1113 is($data[0]->{type}, 'HEADERS', 'response CONTINUATION - first'); | |
1114 is($data[0]->{flags}, 0, 'response CONTINUATION - first flags'); | |
1115 is($data[1]->{type}, 'CONTINUATION', 'response CONTINUATION - second'); | |
1116 is($data[1]->{flags}, 0, 'response CONTINUATION - second flags'); | |
1117 is($data[2]->{type}, 'CONTINUATION', 'response CONTINUATION - third'); | |
1118 is($data[2]->{flags}, 4, 'response CONTINUATION - third flags'); | |
1119 | |
1120 # same but without response DATA frames | |
1121 | |
1122 $sess = new_session(); | |
1123 $sid = new_stream($sess, { path => '/continuation/204?h=' . 'x' x 2**13 }); | |
1124 | |
1125 $frames = h2_read($sess, all => [{ sid => $sid, fin => 0x4 }]); | |
1126 @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames; | |
1127 is(@data, 3, 'no body CONTINUATION - header block frames'); | |
1128 is($data[0]->{type}, 'HEADERS', 'no body CONTINUATION - first'); | |
1129 is($data[0]->{flags}, 1, 'no body CONTINUATION - first flags'); | |
1130 is($data[1]->{type}, 'CONTINUATION', 'no body CONTINUATION - second'); | |
1131 is($data[1]->{flags}, 0, 'no body CONTINUATION - second flags'); | |
1132 is($data[2]->{type}, 'CONTINUATION', 'no body CONTINUATION - third'); | |
1133 is($data[2]->{flags}, 4, 'no body CONTINUATION - third flags'); | |
1091 | 1134 |
1092 # max_field_size | 1135 # max_field_size |
1093 | 1136 |
1094 $sess = new_session(8087); | 1137 $sess = new_session(8087); |
1095 $sid = new_stream($sess, { headers => [ | 1138 $sid = new_stream($sess, { headers => [ |