Mercurial > hg > nginx-tests
comparison spdy.t @ 442:cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 24 Jul 2014 21:57:24 +0400 |
parents | 89f7a882d692 |
children | d1c4b0d15484 |
comparison
equal
deleted
inserted
replaced
441:cd61bacbbfe0 | 442:cc4697d6bd16 |
---|---|
36 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | 36 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
37 | 37 |
38 my $t = Test::Nginx->new() | 38 my $t = Test::Nginx->new() |
39 ->has(qw/http proxy cache limit_conn rewrite spdy realip/); | 39 ->has(qw/http proxy cache limit_conn rewrite spdy realip/); |
40 | 40 |
41 $t->plan(76)->write_file_expand('nginx.conf', <<'EOF'); | 41 $t->plan(79)->write_file_expand('nginx.conf', <<'EOF'); |
42 | 42 |
43 %%TEST_GLOBALS%% | 43 %%TEST_GLOBALS%% |
44 | 44 |
45 daemon off; | 45 daemon off; |
46 | 46 |
96 proxy_buffering off; | 96 proxy_buffering off; |
97 } | 97 } |
98 location /t3.html { | 98 location /t3.html { |
99 limit_conn conn 1; | 99 limit_conn conn 1; |
100 } | 100 } |
101 location /set-cookie { | |
102 add_header Set-Cookie val1; | |
103 add_header Set-Cookie val2; | |
104 return 200; | |
105 } | |
106 location /cookie { | |
107 add_header X-Cookie $http_cookie; | |
108 return 200; | |
109 } | |
101 } | 110 } |
102 } | 111 } |
103 | 112 |
104 EOF | 113 EOF |
105 | 114 |
204 is($frame->{headers}->{':status'}, 206, 'SYN_REPLAY status range'); | 213 is($frame->{headers}->{':status'}, 206, 'SYN_REPLAY status range'); |
205 | 214 |
206 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | 215 ($frame) = grep { $_->{type} eq "DATA" } @$frames; |
207 is($frame->{length}, 10, 'DATA length range'); | 216 is($frame->{length}, 10, 'DATA length range'); |
208 is($frame->{data}, '002XXXX000', 'DATA payload range'); | 217 is($frame->{data}, '002XXXX000', 'DATA payload range'); |
218 | |
219 TODO: { | |
220 local $TODO = 'not yet' unless $t->has_version('1.7.4'); | |
221 | |
222 # request header with multiple values | |
223 | |
224 $sess = new_session(); | |
225 $sid1 = spdy_stream($sess, { path => '/cookie', | |
226 headers => { "cookie" => "val1\0val2" } | |
227 }); | |
228 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
229 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), | |
230 'multiple request header values'); | |
231 | |
232 # request header with multiple values proxied to http backend | |
233 | |
234 $sess = new_session(); | |
235 $sid1 = spdy_stream($sess, { path => '/proxy/cookie', | |
236 headers => { "cookie" => "val1\0val2" } | |
237 }); | |
238 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
239 | |
240 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
241 is($frame->{headers}->{'x-cookie'}, 'val1; val2', | |
242 'multiple request header values - proxied'); | |
243 | |
244 } | |
245 | |
246 # response header with multiple values | |
247 | |
248 $sess = new_session(); | |
249 $sid1 = spdy_stream($sess, { path => '/set-cookie' }); | |
250 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
251 | |
252 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
253 is($frame->{headers}->{'set-cookie'}, "val1\0val2", | |
254 'response header with multiple values'); | |
209 | 255 |
210 # $spdy | 256 # $spdy |
211 | 257 |
212 $sess = new_session(); | 258 $sess = new_session(); |
213 $sid1 = spdy_stream($sess, { path => '/spdy' }); | 259 $sid1 = spdy_stream($sess, { path => '/spdy' }); |