Mercurial > hg > nginx-tests
comparison h2_variables.t @ 1286:b50c8b9a7644
Tests: added HTTP/2 $request_length tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 14 Feb 2018 15:10:55 +0300 |
parents | 882267679006 |
children | a94a0fc60d56 |
comparison
equal
deleted
inserted
replaced
1285:aaf332b74bcf | 1286:b50c8b9a7644 |
---|---|
21 ############################################################################### | 21 ############################################################################### |
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite/)->plan(4) | 26 my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite/)->plan(6) |
27 ->write_file_expand('nginx.conf', <<'EOF'); | 27 ->write_file_expand('nginx.conf', <<'EOF'); |
28 | 28 |
29 %%TEST_GLOBALS%% | 29 %%TEST_GLOBALS%% |
30 | 30 |
31 daemon off; | 31 daemon off; |
49 location /scheme { | 49 location /scheme { |
50 return 200 $scheme; | 50 return 200 $scheme; |
51 } | 51 } |
52 location /https { | 52 location /https { |
53 return 200 $https; | 53 return 200 $https; |
54 } | |
55 location /rl { | |
56 return 200 $request_length; | |
54 } | 57 } |
55 } | 58 } |
56 } | 59 } |
57 | 60 |
58 EOF | 61 EOF |
95 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 98 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
96 | 99 |
97 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | 100 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
98 is($frame->{data}, '', 'https variable'); | 101 is($frame->{data}, '', 'https variable'); |
99 | 102 |
103 # $request_length, HEADERS payload length | |
104 | |
105 $s = Test::Nginx::HTTP2->new(); | |
106 $sid = $s->new_stream({ headers => [ | |
107 { name => ':method', value => 'GET', mode => 0 }, # 1 | |
108 { name => ':scheme', value => 'http', mode => 0 }, # 1 | |
109 { name => ':authority', value => 'localhost', mode => 1 }, # 1+1+9 | |
110 { name => ':path', value => '/rl', mode => 1 }]}); # 1+1+3 | |
111 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
112 | |
113 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
114 is($frame->{data}, '18', 'request length'); | |
115 | |
116 # $request_length, HEADERS+CONTINUATION payload length | |
117 | |
118 $s = Test::Nginx::HTTP2->new(); | |
119 $sid = $s->new_stream({ continuation => 1, headers => [ | |
120 { name => ':method', value => 'GET', mode => 0 }, # 1 | |
121 { name => ':authority', value => 'localhost', mode => 1 }, # 1+1+9 | |
122 { name => ':path', value => '/rl', mode => 1 }]}); # 1+1+3 | |
123 $s->h2_continue($sid, { headers => [ | |
124 { name => ':scheme', value => 'http', mode => 0 }]}); # 1 | |
125 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
126 | |
127 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
128 is($frame->{data}, '18', 'request length'); | |
129 | |
100 ############################################################################### | 130 ############################################################################### |