Mercurial > hg > nginx-tests
annotate spdy.t @ 554:4cc65166509e
Tests: removed superfluous try_run() check.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 22 Apr 2015 14:38:24 +0300 |
parents | 42810c40ebb8 |
children | 907e89fba9c3 |
rev | line source |
---|---|
374 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for SPDY protocol version 3.1. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use IO::Select; | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
16 use Socket qw/ CRLF /; |
374 | 17 |
18 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
19 | |
20 use lib 'lib'; | |
21 use Test::Nginx; | |
22 | |
23 ############################################################################### | |
24 | |
25 select STDERR; $| = 1; | |
26 select STDOUT; $| = 1; | |
27 | |
28 eval { | |
29 require Compress::Raw::Zlib; | |
30 Compress::Raw::Zlib->Z_OK; | |
31 Compress::Raw::Zlib->Z_SYNC_FLUSH; | |
32 Compress::Raw::Zlib->Z_NO_COMPRESSION; | |
33 Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB; | |
34 }; | |
35 plan(skip_all => 'Compress::Raw::Zlib not installed') if $@; | |
36 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | |
37 | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
38 my $t = Test::Nginx->new() |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
39 ->has(qw/http proxy cache limit_conn rewrite spdy realip/); |
374 | 40 |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
41 $t->plan(82)->write_file_expand('nginx.conf', <<'EOF'); |
374 | 42 |
43 %%TEST_GLOBALS%% | |
44 | |
45 daemon off; | |
46 | |
47 events { | |
48 } | |
49 | |
50 http { | |
51 %%TEST_GLOBALS_HTTP%% | |
52 | |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
488
diff
changeset
|
53 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; |
374 | 54 limit_conn_zone $binary_remote_addr zone=conn:1m; |
55 | |
56 server { | |
57 listen 127.0.0.1:8080 spdy; | |
58 listen 127.0.0.1:8081; | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
59 listen 127.0.0.1:8082 proxy_protocol spdy; |
374 | 60 server_name localhost; |
61 | |
62 location /s { | |
63 add_header X-Header X-Foo; | |
64 return 200 'body'; | |
65 } | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
66 location /pp { |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
67 set_real_ip_from 127.0.0.1/32; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
68 real_ip_header proxy_protocol; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
69 alias %%TESTDIR%%/t2.html; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
70 add_header X-PP $remote_addr; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
71 } |
374 | 72 location /spdy { |
73 return 200 $spdy; | |
74 } | |
75 location /prio { | |
76 return 200 $spdy_request_priority; | |
77 } | |
78 location /chunk_size { | |
79 spdy_chunk_size 1; | |
80 return 200 'body'; | |
81 } | |
82 location /redirect { | |
83 error_page 405 /s; | |
84 return 405; | |
85 } | |
86 location /proxy { | |
87 add_header X-Body "$request_body"; | |
88 proxy_pass http://127.0.0.1:8081/; | |
89 proxy_cache NAME; | |
90 proxy_cache_valid 1m; | |
91 } | |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
92 location /header/ { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
93 proxy_pass http://127.0.0.1:8083/; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
94 } |
428
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
95 location /proxy_buffering_off { |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
96 proxy_pass http://127.0.0.1:8081/; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
97 proxy_cache NAME; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
98 proxy_cache_valid 1m; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
99 proxy_buffering off; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
100 } |
374 | 101 location /t3.html { |
102 limit_conn conn 1; | |
103 } | |
442
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
104 location /set-cookie { |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
105 add_header Set-Cookie val1; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
106 add_header Set-Cookie val2; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
107 return 200; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
108 } |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
109 location /cookie { |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
110 add_header X-Cookie $http_cookie; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
111 return 200; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
112 } |
374 | 113 } |
114 } | |
115 | |
116 EOF | |
117 | |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
118 $t->run_daemon(\&http_daemon); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
119 $t->run()->waitforsocket('127.0.0.1:8083'); |
374 | 120 |
121 # file size is slightly beyond initial window size: 2**16 + 80 bytes | |
122 | |
123 $t->write_file('t1.html', | |
124 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202))); | |
125 | |
126 $t->write_file('t2.html', 'SEE-THIS'); | |
127 $t->write_file('t3.html', 'SEE-THIS'); | |
128 | |
129 my %cframe = ( | |
130 2 => \&syn_reply, | |
131 3 => \&rst_stream, | |
132 4 => \&settings, | |
133 6 => \&ping, | |
134 7 => \&goaway, | |
135 9 => \&window_update | |
136 ); | |
137 | |
138 ############################################################################### | |
139 | |
140 # PING | |
141 | |
142 my $sess = new_session(); | |
143 spdy_ping($sess, 0x12345678); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
144 my $frames = spdy_read($sess, all => [{ type => 'PING' }]); |
374 | 145 |
146 my ($frame) = grep { $_->{type} eq "PING" } @$frames; | |
147 ok($frame, 'PING frame'); | |
148 is($frame->{value}, 0x12345678, 'PING payload'); | |
149 | |
150 # GET | |
151 | |
152 $sess = new_session(); | |
153 my $sid1 = spdy_stream($sess, { path => '/s' }); | |
154 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
155 | |
156 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
157 ok($frame, 'SYN_REPLAY frame'); | |
158 is($frame->{sid}, $sid1, 'SYN_REPLAY stream'); | |
159 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status'); | |
160 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header'); | |
161 | |
162 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
163 ok($frame, 'DATA frame'); | |
164 is($frame->{length}, length 'body', 'DATA length'); | |
165 is($frame->{data}, 'body', 'DATA payload'); | |
166 | |
167 # GET in new SPDY stream in same session | |
168 | |
169 my $sid2 = spdy_stream($sess, { path => '/s' }); | |
170 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]); | |
171 | |
172 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
173 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2'); | |
174 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status 2'); | |
175 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header 2'); | |
176 | |
177 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
178 ok($frame, 'DATA frame 2'); | |
179 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2'); | |
180 is($frame->{length}, length 'body', 'DATA length 2'); | |
181 is($frame->{data}, 'body', 'DATA payload 2'); | |
182 | |
183 # HEAD | |
184 | |
185 $sess = new_session(); | |
186 $sid1 = spdy_stream($sess, { path => '/s', method => 'HEAD' }); | |
187 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
188 | |
189 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
190 is($frame->{sid}, $sid1, 'SYN_REPLAY stream HEAD'); | |
191 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status HEAD'); | |
192 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header HEAD'); | |
193 | |
194 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
195 is($frame, undef, 'HEAD no body'); | |
196 | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
197 # GET with PROXY protocol |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
198 |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
199 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
200 $sess = new_session(8082, proxy => $proxy); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
201 $sid1 = spdy_stream($sess, { path => '/pp' }); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
202 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
203 |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
204 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
205 ok($frame, 'PROXY SYN_REPLAY frame'); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
206 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr'); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
207 |
374 | 208 # request header |
209 | |
210 $sess = new_session(); | |
211 $sid1 = spdy_stream($sess, { path => '/t1.html', | |
212 headers => { "range" => "bytes=10-19" } | |
213 }); | |
214 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
215 | |
216 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
217 is($frame->{headers}->{':status'}, 206, 'SYN_REPLAY status range'); | |
218 | |
219 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
220 is($frame->{length}, 10, 'DATA length range'); | |
221 is($frame->{data}, '002XXXX000', 'DATA payload range'); | |
222 | |
442
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
223 TODO: { |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
224 local $TODO = 'not yet' unless $t->has_version('1.7.4'); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
225 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
226 # request header with multiple values |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
227 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
228 $sess = new_session(); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
229 $sid1 = spdy_stream($sess, { path => '/cookie', |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
230 headers => { "cookie" => "val1\0val2" } |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
231 }); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
232 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
233 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
234 'multiple request header values'); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
235 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
236 # request header with multiple values proxied to http backend |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
237 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
238 $sess = new_session(); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
239 $sid1 = spdy_stream($sess, { path => '/proxy/cookie', |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
240 headers => { "cookie" => "val1\0val2" } |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
241 }); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
242 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
243 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
244 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
245 is($frame->{headers}->{'x-cookie'}, 'val1; val2', |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
246 'multiple request header values - proxied'); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
247 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
248 } |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
249 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
250 # response header with multiple values |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
251 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
252 $sess = new_session(); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
253 $sid1 = spdy_stream($sess, { path => '/set-cookie' }); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
254 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
255 |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
256 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
257 is($frame->{headers}->{'set-cookie'}, "val1\0val2", |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
258 'response header with multiple values'); |
cc4697d6bd16
Tests: added SPDY tests for header field with multiple values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
429
diff
changeset
|
259 |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
260 # response header with multiple values - no empty values inside |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
261 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
262 TODO: { |
488
8474d27c9147
Tests: adjusted SPDY TODOs, fix committed.
Sergey Kandaurov <pluknet@nginx.com>
parents:
487
diff
changeset
|
263 local $TODO = 'not yet' unless $t->has_version('1.7.8'); |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
264 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
265 $sess = new_session(); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
266 $sid1 = spdy_stream($sess, { path => '/header/inside' }); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
267 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
268 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
269 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
270 is($frame->{headers}->{'x-foo'}, "val1\0val2", 'no empty header value inside'); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
271 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
272 $sid1 = spdy_stream($sess, { path => '/header/first' }); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
273 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
274 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
275 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
276 is($frame->{headers}->{'x-foo'}, "val1\0val2", 'no empty header value first'); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
277 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
278 $sid1 = spdy_stream($sess, { path => '/header/last' }); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
279 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
280 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
281 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
282 is($frame->{headers}->{'x-foo'}, "val1\0val2", 'no empty header value last'); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
283 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
284 } |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
285 |
374 | 286 # $spdy |
287 | |
288 $sess = new_session(); | |
289 $sid1 = spdy_stream($sess, { path => '/spdy' }); | |
290 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
291 | |
292 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
293 is($frame->{data}, '3.1', 'spdy variable'); | |
294 | |
295 # spdy_chunk_size=1 | |
296 | |
297 $sess = new_session(); | |
298 $sid1 = spdy_stream($sess, { path => '/chunk_size' }); | |
299 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
300 | |
301 my @data = grep { $_->{type} eq "DATA" } @$frames; | |
302 is(@data, 4, 'chunk_size body chunks'); | |
303 is($data[0]->{data}, 'b', 'chunk_size body 1'); | |
304 is($data[1]->{data}, 'o', 'chunk_size body 2'); | |
305 is($data[2]->{data}, 'd', 'chunk_size body 3'); | |
306 is($data[3]->{data}, 'y', 'chunk_size body 4'); | |
307 | |
308 # redirect | |
309 | |
310 $sess = new_session(); | |
311 $sid1 = spdy_stream($sess, { path => '/redirect' }); | |
312 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
313 | |
314 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
315 is($frame->{headers}->{':status'}, 405, 'SYN_REPLAY status with redirect'); | |
316 | |
317 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
318 ok($frame, 'DATA frame with redirect'); | |
319 is($frame->{data}, 'body', 'DATA payload with redirect'); | |
320 | |
428
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
321 # SYN_REPLY could be received with fin, followed by DATA |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
322 |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
323 $sess = new_session(); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
324 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html', method => 'HEAD' }); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
325 |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
326 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
327 push @$frames, $_ for @{spdy_read($sess, all => [{ sid => $sid1 }])}; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
328 ok(!grep ({ $_->{type} eq "DATA" } @$frames), 'proxy cache HEAD - no body'); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
329 |
374 | 330 # ensure that HEAD-like requests, i.e., without response body, do not lead to |
331 # client connection close due to cache filling up with upstream response body | |
332 | |
333 TODO: { | |
429
89f7a882d692
Tests: spdy.t TODO updated.
Maxim Dounin <mdounin@mdounin.ru>
parents:
428
diff
changeset
|
334 local $TODO = 'premature client connection close' |
89f7a882d692
Tests: spdy.t TODO updated.
Maxim Dounin <mdounin@mdounin.ru>
parents:
428
diff
changeset
|
335 unless $t->has_version('1.7.3'); |
374 | 336 |
337 $sid2 = spdy_stream($sess, { path => '/' }); | |
443
d1c4b0d15484
Tests: fixed SPDY test for premature client connection close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
442
diff
changeset
|
338 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]); |
374 | 339 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), 'proxy cache headers only'); |
340 | |
341 } | |
342 | |
428
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
343 # HEAD on empty cache with proxy_buffering off |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
344 |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
345 $sess = new_session(); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
346 $sid1 = spdy_stream($sess, |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
347 { path => '/proxy_buffering_off/t2.html?1', method => 'HEAD' }); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
348 |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
349 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
350 push @$frames, $_ for @{spdy_read($sess, all => [{ sid => $sid1 }])}; |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
351 ok(!grep ({ $_->{type} eq "DATA" } @$frames), |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
352 'proxy cache HEAD buffering off - no body'); |
e95c3340d94a
Tests: more SPDY tests for caching HEAD requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
427
diff
changeset
|
353 |
374 | 354 # simple proxy cache test |
355 | |
356 $sess = new_session(); | |
357 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html' }); | |
358 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
359 | |
360 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
361 is($frame->{headers}->{':status'}, '200 OK', 'proxy cache unconditional'); | |
362 | |
363 $sid2 = spdy_stream($sess, { path => '/proxy/t2.html', | |
416
5c25acbc870a
Tests: etags support is present in all supported branches.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
364 headers => { "if-none-match" => $frame->{headers}->{'etag'} } |
374 | 365 }); |
366 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]); | |
367 | |
368 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
369 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional'); | |
370 | |
371 # request body (uses proxied response) | |
372 | |
373 $sess = new_session(); | |
374 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html', body => 'TEST' }); | |
375 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
376 | |
377 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
378 is($frame->{headers}->{'x-body'}, 'TEST', 'request body'); | |
379 | |
380 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
381 is($frame->{length}, length 'SEE-THIS', 'proxied response length'); | |
382 is($frame->{data}, 'SEE-THIS', 'proxied response'); | |
383 | |
384 # WINDOW_UPDATE (client side) | |
385 | |
386 $sess = new_session(); | |
387 $sid1 = spdy_stream($sess, { path => '/t1.html' }); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
388 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]); |
374 | 389 |
390 @data = grep { $_->{type} eq "DATA" } @$frames; | |
391 my $sum = eval join '+', map { $_->{length} } @data; | |
392 is($sum, 2**16, 'iws - stream blocked on initial window size'); | |
393 | |
394 spdy_ping($sess, 0xf00ff00f); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
395 $frames = spdy_read($sess, all => [{ type => 'PING' }]); |
374 | 396 |
397 ($frame) = grep { $_->{type} eq "PING" } @$frames; | |
398 ok($frame, 'iws - PING not blocked'); | |
399 | |
400 spdy_window($sess, 2**16, $sid1); | |
401 $frames = spdy_read($sess); | |
402 is(@$frames, 0, 'iws - updated stream window'); | |
403 | |
404 spdy_window($sess, 2**16); | |
405 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
406 | |
407 @data = grep { $_->{type} eq "DATA" } @$frames; | |
408 $sum = eval join '+', map { $_->{length} } @data; | |
409 is($sum, 80, 'iws - updated connection window'); | |
410 | |
411 # SETTINGS (initial window size, client side) | |
412 | |
413 $sess = new_session(); | |
414 spdy_settings($sess, 7 => 2**17); | |
415 spdy_window($sess, 2**17); | |
416 | |
417 $sid1 = spdy_stream($sess, { path => '/t1.html' }); | |
418 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
419 | |
420 @data = grep { $_->{type} eq "DATA" } @$frames; | |
421 $sum = eval join '+', map { $_->{length} } @data; | |
422 is($sum, 2**16 + 80, 'increased initial window size'); | |
423 | |
424 # probe for negative available space in a flow control window | |
425 | |
426 $sess = new_session(); | |
427 $sid1 = spdy_stream($sess, { path => '/t1.html' }); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
428 spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]); |
374 | 429 |
430 spdy_window($sess, 1); | |
431 spdy_settings($sess, 7 => 42); | |
432 spdy_window($sess, 1024, $sid1); | |
433 | |
434 $frames = spdy_read($sess); | |
435 is(@$frames, 0, 'negative window - no data'); | |
436 | |
437 spdy_window($sess, 2**16 - 42 - 1024, $sid1); | |
438 $frames = spdy_read($sess); | |
439 is(@$frames, 0, 'zero window - no data'); | |
440 | |
441 spdy_window($sess, 1, $sid1); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
442 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 1 }]); |
374 | 443 is(@$frames, 1, 'positive window - data'); |
444 is(@$frames[0]->{length}, 1, 'positive window - data length'); | |
445 | |
446 # stream multiplexing | |
447 | |
448 $sess = new_session(); | |
449 $sid1 = spdy_stream($sess, { path => '/t1.html' }); | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
450 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]); |
374 | 451 |
452 @data = grep { $_->{type} eq "DATA" } @$frames; | |
453 $sum = eval join '+', map { $_->{length} } @data; | |
454 is($sum, 2**16, 'multiple - stream1 data'); | |
455 | |
456 $sid2 = spdy_stream($sess, { path => '/t1.html' }); | |
457 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]); | |
458 | |
459 @data = grep { $_->{type} eq "DATA" } @$frames; | |
460 is(@data, 0, 'multiple - stream2 no data'); | |
461 | |
462 spdy_window($sess, 2**17, $sid1); | |
463 spdy_window($sess, 2**17, $sid2); | |
464 spdy_window($sess, 2**17); | |
465 | |
466 $frames = spdy_read($sess, all => [ | |
467 { sid => $sid1, fin => 1 }, | |
468 { sid => $sid2, fin => 1 } | |
469 ]); | |
470 | |
471 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid1 } @$frames; | |
472 $sum = eval join '+', map { $_->{length} } @data; | |
473 is($sum, 80, 'multiple - stream1 remain data'); | |
474 | |
475 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames; | |
476 $sum = eval join '+', map { $_->{length} } @data; | |
477 is($sum, 2**16 + 80, 'multiple - stream2 full data'); | |
478 | |
479 # request priority parsing in $spdy_request_priority | |
480 | |
481 $sess = new_session(); | |
482 $sid1 = spdy_stream($sess, { path => '/prio', prio => 0 }); | |
483 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
484 | |
485 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
486 is($frame->{data}, 0, 'priority 0'); | |
487 | |
488 $sid1 = spdy_stream($sess, { path => '/prio', prio => 1 }); | |
489 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
490 | |
491 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
492 is($frame->{data}, 1, 'priority 1'); | |
493 | |
494 $sid1 = spdy_stream($sess, { path => '/prio', prio => 7 }); | |
495 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
496 | |
497 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
498 is($frame->{data}, 7, 'priority 7'); | |
499 | |
500 # stream muliplexing + priority | |
501 | |
502 $sess = new_session(); | |
503 $sid1 = spdy_stream($sess, { path => '/t1.html', prio => 7 }); | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
504 spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
505 |
374 | 506 $sid2 = spdy_stream($sess, { path => '/t2.html', prio => 0 }); |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
507 spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]); |
374 | 508 |
509 spdy_window($sess, 2**17, $sid1); | |
510 spdy_window($sess, 2**17, $sid2); | |
511 spdy_window($sess, 2**17); | |
512 | |
513 $frames = spdy_read($sess, all => [ | |
514 { sid => $sid1, fin => 1 }, | |
515 { sid => $sid2, fin => 1 } | |
516 ]); | |
517 | |
518 @data = grep { $_->{type} eq "DATA" } @$frames; | |
519 is(join (' ', map { $_->{sid} } @data), "$sid2 $sid1", 'multiple priority 1'); | |
520 | |
521 # and vice versa | |
522 | |
523 $sess = new_session(); | |
524 $sid1 = spdy_stream($sess, { path => '/t1.html', prio => 0 }); | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
525 spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
526 |
374 | 527 $sid2 = spdy_stream($sess, { path => '/t2.html', prio => 7 }); |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
528 spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]); |
374 | 529 |
530 spdy_window($sess, 2**17, $sid1); | |
531 spdy_window($sess, 2**17, $sid2); | |
532 spdy_window($sess, 2**17); | |
533 | |
534 $frames = spdy_read($sess, all => [ | |
535 { sid => $sid1, fin => 1 }, | |
536 { sid => $sid2, fin => 1 } | |
537 ]); | |
538 | |
539 @data = grep { $_->{type} eq "DATA" } @$frames; | |
540 is(join (' ', map { $_->{sid} } @data), "$sid1 $sid2", 'multiple priority 2'); | |
541 | |
542 # limit_conn | |
543 | |
544 $sess = new_session(); | |
545 spdy_settings($sess, 7 => 1); | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
546 |
374 | 547 $sid1 = spdy_stream($sess, { path => '/t3.html' }); |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
548 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 0 }]); |
374 | 549 |
550 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames; | |
551 is($frame->{headers}->{':status'}, 200, 'conn_limit 1'); | |
552 | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
553 $sid2 = spdy_stream($sess, { path => '/t3.html' }); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
554 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
555 |
374 | 556 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames; |
557 is($frame->{headers}->{':status'}, 503, 'conn_limit 2'); | |
558 | |
470
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
559 spdy_settings($sess, 7 => 2**16); |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
560 |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
561 spdy_read($sess, all => [ |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
562 { sid => $sid1, fin => 1 }, |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
563 { sid => $sid2, fin => 1 } |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
564 ]); |
00275fa9091c
Tests: fixed SPDY test with limit_conn.
Sergey Kandaurov <pluknet@nginx.com>
parents:
443
diff
changeset
|
565 |
374 | 566 # limit_conn + client's RST_STREAM |
567 | |
568 $sess = new_session(); | |
569 spdy_settings($sess, 7 => 1); | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
570 |
374 | 571 $sid1 = spdy_stream($sess, { path => '/t3.html' }); |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
572 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 0 }]); |
374 | 573 spdy_rst($sess, $sid1, 5); |
574 | |
575 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames; | |
576 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1'); | |
577 | |
529
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
578 $sid2 = spdy_stream($sess, { path => '/t3.html' }); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
579 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]); |
42810c40ebb8
Tests: removed races from SPDY tests with consecutive streams.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
580 |
374 | 581 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames; |
582 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2'); | |
583 | |
584 # GOAWAY on SYN_STREAM with even StreamID | |
585 | |
586 TODO: { | |
587 local $TODO = 'not yet'; | |
588 | |
589 $sess = new_session(); | |
590 spdy_stream($sess, { path => '/s' }, 2); | |
591 $frames = spdy_read($sess); | |
592 | |
593 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
594 ok($frame, 'even stream - GOAWAY frame'); | |
595 is($frame->{code}, 1, 'even stream - error code'); | |
596 is($frame->{sid}, 0, 'even stream - last used stream'); | |
597 | |
598 } | |
599 | |
600 # GOAWAY on SYN_STREAM with backward StreamID | |
601 | |
602 TODO: { | |
603 local $TODO = 'not yet'; | |
604 | |
605 $sess = new_session(); | |
606 $sid1 = spdy_stream($sess, { path => '/s' }, 3); | |
607 spdy_read($sess); | |
608 | |
609 $sid2 = spdy_stream($sess, { path => '/s' }, 1); | |
610 $frames = spdy_read($sess); | |
611 | |
612 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
613 ok($frame, 'backward stream - GOAWAY frame'); | |
614 is($frame->{code}, 1, 'backward stream - error code'); | |
615 is($frame->{sid}, $sid1, 'backward stream - last used stream'); | |
616 | |
617 } | |
618 | |
619 # RST_STREAM on the second SYN_STREAM with same StreamID | |
620 | |
621 TODO: { | |
622 local $TODO = 'not yet'; | |
623 | |
624 $sess = new_session(); | |
625 $sid1 = spdy_stream($sess, { path => '/s' }, 3); | |
626 spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
627 $sid2 = spdy_stream($sess, { path => '/s' }, 3); | |
628 $frames = spdy_read($sess); | |
629 | |
630 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | |
631 ok($frame, 'dup stream - RST_STREAM frame'); | |
632 is($frame->{code}, 1, 'dup stream - error code'); | |
633 is($frame->{sid}, $sid1, 'dup stream - stream'); | |
634 | |
635 } | |
636 | |
637 # awkward protocol version | |
638 | |
639 $sess = new_session(); | |
640 $sid1 = spdy_stream($sess, { path => '/s', version => 'HTTP/1.10' }); | |
641 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
642 | |
643 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
644 is($frame->{headers}->{':status'}, 200, 'awkward version'); | |
645 | |
646 # missing mandatory request header | |
647 | |
648 $sess = new_session(); | |
649 $sid1 = spdy_stream($sess, { path => '/s', version => '' }); | |
650 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]); | |
651 | |
652 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames; | |
653 is($frame->{headers}->{':status'}, 400, 'incomplete headers'); | |
654 | |
655 # GOAWAY before closing a connection by server | |
656 | |
657 $t->stop(); | |
658 | |
659 TODO: { | |
660 local $TODO = 'not yet'; | |
661 | |
662 $frames = spdy_read($sess); | |
663 | |
664 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
665 ok($frame, 'GOAWAY on connection close'); | |
666 | |
667 } | |
668 | |
669 ############################################################################### | |
670 | |
671 sub spdy_ping { | |
672 my ($sess, $payload) = @_; | |
673 | |
674 raw_write($sess->{socket}, pack("N3", 0x80030006, 0x4, $payload)); | |
675 } | |
676 | |
677 sub spdy_rst { | |
678 my ($sess, $sid, $error) = @_; | |
679 | |
680 raw_write($sess->{socket}, pack("N4", 0x80030003, 0x8, $sid, $error)); | |
681 } | |
682 | |
683 sub spdy_window { | |
684 my ($sess, $win, $stream) = @_; | |
685 | |
686 $stream = 0 unless defined $stream; | |
687 raw_write($sess->{socket}, pack("N4", 0x80030009, 8, $stream, $win)); | |
688 } | |
689 | |
690 sub spdy_settings { | |
691 my ($sess, %extra) = @_; | |
692 | |
693 my $cnt = keys %extra; | |
694 my $len = 4 + 8 * $cnt; | |
695 | |
696 my $buf = pack "N3", 0x80030004, $len, $cnt; | |
697 $buf .= join '', map { pack "N2", $_, $extra{$_} } keys %extra; | |
698 raw_write($sess->{socket}, $buf); | |
699 } | |
700 | |
701 sub spdy_read { | |
702 my ($sess, %extra) = @_; | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
703 my ($length, @got); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
704 my $s = $sess->{socket}; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
705 my $buf = ''; |
374 | 706 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
707 eval { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
708 local $SIG{ALRM} = sub { die "timeout\n" }; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
709 local $SIG{PIPE} = sub { die "sigpipe\n" }; |
374 | 710 again: |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
711 alarm(1); |
374 | 712 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
713 $buf = raw_read($s, $buf, 8); |
379
f42de3a9fd74
Tests: avoid uninitialized warnings in spdy.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
377
diff
changeset
|
714 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
715 my $type = unpack("B", $buf); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
716 $length = 8 + hex unpack("x5 H6", $buf); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
717 $buf = raw_read($s, $buf, $length); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
718 |
374 | 719 if ($type == 0) { |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
720 push @got, dframe($buf); |
374 | 721 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
722 } else { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
723 my $ctype = unpack("x2 n", $buf); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
724 push @got, $cframe{$ctype}($sess, $buf); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
725 } |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
726 $buf = substr($buf, $length); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
727 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
728 goto again if test_fin($got[-1], $extra{all}); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
729 alarm(0); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
730 }; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
731 alarm(0); |
374 | 732 return \@got; |
733 } | |
734 | |
735 sub test_fin { | |
736 my ($frame, $all) = @_; | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
737 my @test = @{$all}; |
374 | 738 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
739 # wait for the specified DATA length |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
740 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
741 for (@test) { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
742 if ($_->{length} && $frame->{type} eq 'DATA') { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
743 # check also for StreamID if needed |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
744 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
745 if (!$_->{sid} || $_->{sid} == $frame->{sid}) { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
746 $_->{length} -= $frame->{length}; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
747 } |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
748 } |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
749 } |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
750 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
751 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
752 # wait for the fin flag |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
753 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
754 @test = grep { !(defined $_->{fin} |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
755 && $_->{sid} == $frame->{sid} && $_->{fin} == $frame->{fin}) |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
756 } @test if defined $frame->{fin}; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
757 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
758 # wait for the specified frame |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
759 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
760 @test = grep { !($_->{type} && $_->{type} eq $frame->{type}) } @test; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
761 |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
762 @{$all} = @test; |
374 | 763 } |
764 | |
765 sub dframe { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
766 my ($buf) = @_; |
374 | 767 my %frame; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
768 my $skip = 0; |
374 | 769 |
770 my $stream = unpack "\@$skip B32", $buf; $skip += 4; | |
771 substr($stream, 0, 1) = 0; | |
772 $stream = unpack("N", pack("B32", $stream)); | |
773 $frame{sid} = $stream; | |
774 | |
775 my $flags = unpack "\@$skip B8", $buf; $skip += 1; | |
776 $frame{fin} = substr($flags, 7, 1); | |
777 | |
778 my $length = hex (unpack "\@$skip H6", $buf); $skip += 3; | |
779 $frame{length} = $length; | |
780 | |
781 $frame{data} = substr($buf, $skip, $length); | |
782 $frame{type} = "DATA"; | |
783 return \%frame; | |
784 } | |
785 | |
786 sub spdy_stream { | |
787 my ($ctx, $uri, $stream) = @_; | |
788 my ($input, $output, $buf); | |
789 my ($d, $status); | |
790 | |
791 my $host = $uri->{host} || '127.0.0.1:8080'; | |
792 my $method = $uri->{method} || 'GET'; | |
793 my $headers = $uri->{headers} || {}; | |
794 my $body = $uri->{body}; | |
795 my $prio = defined $uri->{prio} ? $uri->{prio} : 4; | |
796 my $version = defined $uri->{version} ? $uri->{version} : "HTTP/1.1"; | |
797 | |
798 if ($stream) { | |
799 $ctx->{last_stream} = $stream; | |
800 } else { | |
801 $ctx->{last_stream} += 2; | |
802 } | |
803 | |
804 $buf = pack("NC", 0x80030001, not $body); | |
805 $buf .= pack("xxx"); # Length stub | |
806 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID | |
807 $buf .= pack("N", 0); # Assoc. Stream-ID | |
808 $buf .= pack("n", $prio << 13); | |
809 | |
810 my $ent = 4 + keys %{$headers}; | |
811 $ent++ if $body; | |
812 $ent++ if $version; | |
813 | |
814 $input = pack("N", $ent); | |
815 $input .= hpack(":host", $host); | |
816 $input .= hpack(":method", $method); | |
817 $input .= hpack(":path", $uri->{path}); | |
818 $input .= hpack(":scheme", "http"); | |
819 if ($version) { | |
820 $input .= hpack(":version", $version); | |
821 } | |
822 if ($body) { | |
823 $input .= hpack("content-length", length $body); | |
824 } | |
825 $input .= join '', map { hpack($_, $headers->{$_}) } keys %{$headers}; | |
826 | |
827 $d = $ctx->{zlib}->{d}; | |
828 $status = $d->deflate($input => \my $start); | |
829 $status == Compress::Raw::Zlib->Z_OK or fail "deflate failed"; | |
830 $status = $d->flush(\my $tail => Compress::Raw::Zlib->Z_SYNC_FLUSH); | |
831 $status == Compress::Raw::Zlib->Z_OK or fail "flush failed"; | |
832 $output = $start . $tail; | |
833 | |
426
7cb6af00afdd
Tests: fixed SPDY tests with large header length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
425
diff
changeset
|
834 # set length, attach headers and optional body |
7cb6af00afdd
Tests: fixed SPDY tests with large header length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
425
diff
changeset
|
835 |
7cb6af00afdd
Tests: fixed SPDY tests with large header length.
Sergey Kandaurov <pluknet@nginx.com>
parents:
425
diff
changeset
|
836 $buf |= pack "x4N", length($output) + 10; |
374 | 837 $buf .= $output; |
838 | |
839 if (defined $body) { | |
840 $buf .= pack "NCxn", $ctx->{last_stream}, 0x01, length $body; | |
841 $buf .= $body; | |
842 } | |
843 | |
844 raw_write($ctx->{socket}, $buf); | |
845 return $ctx->{last_stream}; | |
846 } | |
847 | |
848 sub syn_reply { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
849 my ($ctx, $buf) = @_; |
374 | 850 my ($i, $status); |
851 my %payload; | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
852 my $skip = 4; |
374 | 853 |
854 my $flags = unpack "\@$skip B8", $buf; $skip += 1; | |
855 $payload{fin} = substr($flags, 7, 1); | |
856 | |
857 my $length = hex unpack "\@$skip H6", $buf; $skip += 3; | |
858 $payload{length} = $length; | |
859 $payload{type} = 'SYN_REPLY'; | |
860 | |
861 my $stream = unpack "\@$skip B32", $buf; $skip += 4; | |
862 substr($stream, 0, 1) = 0; | |
863 $stream = unpack("N", pack("B32", $stream)); | |
864 $payload{sid} = $stream; | |
865 | |
866 my $input = substr($buf, $skip, $length - 4); | |
867 $i = $ctx->{zlib}->{i}; | |
868 | |
869 $status = $i->inflate($input => \my $out); | |
870 fail "Failed: $status" unless $status == Compress::Raw::Zlib->Z_OK; | |
871 $payload{headers} = hunpack($out); | |
872 return \%payload; | |
873 } | |
874 | |
875 sub rst_stream { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
876 my ($ctx, $buf) = @_; |
374 | 877 my %payload; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
878 my $skip = 5; |
374 | 879 |
880 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3; | |
881 $payload{type} = 'RST_STREAM'; | |
882 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4; | |
883 $payload{code} = unpack "\@$skip N", $buf; | |
884 return \%payload; | |
885 } | |
886 | |
887 sub settings { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
888 my ($ctx, $buf) = @_; |
374 | 889 my %payload; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
890 my $skip = 4; |
374 | 891 |
892 $payload{flags} = unpack "\@$skip H", $buf; $skip += 1; | |
893 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3; | |
894 $payload{type} = 'SETTINGS'; | |
895 | |
896 my $nent = unpack "\@$skip N", $buf; $skip += 4; | |
897 for (1 .. $nent) { | |
898 my $flags = hex unpack "\@$skip H2", $buf; $skip += 1; | |
899 my $id = hex unpack "\@$skip H6", $buf; $skip += 3; | |
900 $payload{$id}{flags} = $flags; | |
901 $payload{$id}{value} = unpack "\@$skip N", $buf; $skip += 4; | |
902 } | |
903 return \%payload; | |
904 } | |
905 | |
906 sub ping { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
907 my ($ctx, $buf) = @_; |
374 | 908 my %payload; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
909 my $skip = 5; |
374 | 910 |
911 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3; | |
912 $payload{type} = 'PING'; | |
913 $payload{value} = unpack "\@$skip N", $buf; | |
914 return \%payload; | |
915 } | |
916 | |
917 sub goaway { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
918 my ($ctx, $buf) = @_; |
374 | 919 my %payload; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
920 my $skip = 5; |
374 | 921 |
922 $payload{length} = hex unpack "\@$skip H6", $buf; $skip += 3; | |
923 $payload{type} = 'GOAWAY'; | |
924 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4; | |
925 $payload{code} = unpack "\@$skip N", $buf; | |
926 return \%payload; | |
927 } | |
928 | |
929 sub window_update { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
930 my ($ctx, $buf) = @_; |
374 | 931 my %payload; |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
932 my $skip = 5; |
374 | 933 |
934 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3; | |
935 $payload{type} = 'WINDOW_UPDATE'; | |
936 | |
937 my $stream = unpack "\@$skip B32", $buf; $skip += 4; | |
938 substr($stream, 0, 1) = 0; | |
939 $stream = unpack("N", pack("B32", $stream)); | |
940 $payload{sid} = $stream; | |
941 | |
942 my $value = unpack "\@$skip B32", $buf; | |
943 substr($value, 0, 1) = 0; | |
944 $payload{wdelta} = unpack("N", pack("B32", $value)); | |
945 return \%payload; | |
946 } | |
947 | |
948 sub hpack { | |
949 my ($name, $value) = @_; | |
950 | |
951 pack("N", length($name)) . $name . pack("N", length($value)) . $value; | |
952 } | |
953 | |
954 sub hunpack { | |
955 my ($data) = @_; | |
956 my %headers; | |
957 my $skip = 0; | |
958 | |
959 my $nent = unpack "\@$skip N", $data; $skip += 4; | |
960 for (1 .. $nent) { | |
961 my $len = unpack("\@$skip N", $data); $skip += 4; | |
962 my $name = unpack("\@$skip A$len", $data); $skip += $len; | |
963 | |
964 $len = unpack("\@$skip N", $data); $skip += 4; | |
965 my $value = unpack("\@$skip A$len", $data); $skip += $len; | |
486
c2c1eb6d7a76
Tests: worked around a bug in perl unpack.
Sergey Kandaurov <pluknet@nginx.com>
parents:
470
diff
changeset
|
966 $value .= "\0" x ($len - length $value); |
374 | 967 |
968 $headers{$name} = $value; | |
969 } | |
970 return \%headers; | |
971 } | |
972 | |
973 sub raw_read { | |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
974 my ($s, $buf, $len) = @_; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
975 my $got = ''; |
374 | 976 |
425
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
977 while (length($buf) < $len) { |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
978 $s->sysread($got, $len - length($buf)) or die; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
979 log_in($got); |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
980 $buf .= $got; |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
981 } |
cc7da696a330
Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
416
diff
changeset
|
982 return $buf; |
374 | 983 } |
984 | |
985 sub raw_write { | |
986 my ($s, $message) = @_; | |
987 | |
988 local $SIG{PIPE} = 'IGNORE'; | |
989 | |
990 while (IO::Select->new($s)->can_write(0.4)) { | |
991 log_out($message); | |
992 my $n = $s->syswrite($message); | |
993 last unless $n; | |
994 $message = substr($message, $n); | |
995 last unless length $message; | |
996 } | |
997 } | |
998 | |
999 sub new_session { | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1000 my ($port, %extra) = @_; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1001 my ($d, $i, $status, $s); |
374 | 1002 |
1003 ($d, $status) = Compress::Raw::Zlib::Deflate->new( | |
1004 -WindowBits => 12, | |
1005 -Dictionary => dictionary(), | |
1006 -Level => Compress::Raw::Zlib->Z_NO_COMPRESSION | |
1007 ); | |
1008 fail "Zlib failure: $status" unless $d; | |
1009 | |
1010 ($i, $status) = Compress::Raw::Zlib::Inflate->new( | |
1011 -WindowBits => Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB, | |
1012 -Dictionary => dictionary() | |
1013 ); | |
1014 fail "Zlib failure: $status" unless $i; | |
1015 | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1016 $s = new_socket($port); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1017 |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1018 if ($extra{proxy}) { |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1019 raw_write($s, $extra{proxy}); |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1020 } |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1021 |
374 | 1022 return { zlib => { i => $i, d => $d }, |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1023 socket => $s, last_stream => -1 }; |
374 | 1024 } |
1025 | |
1026 sub new_socket { | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1027 my ($port) = @_; |
374 | 1028 my $s; |
1029 | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1030 $port = 8080 unless defined $port; |
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1031 |
374 | 1032 eval { |
1033 local $SIG{ALRM} = sub { die "timeout\n" }; | |
1034 local $SIG{PIPE} = sub { die "sigpipe\n" }; | |
1035 alarm(2); | |
1036 $s = IO::Socket::INET->new( | |
1037 Proto => 'tcp', | |
427
daea9cf92c14
Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents:
426
diff
changeset
|
1038 PeerAddr => "127.0.0.1:$port", |
374 | 1039 ); |
1040 alarm(0); | |
1041 }; | |
1042 alarm(0); | |
1043 | |
1044 if ($@) { | |
1045 log_in("died: $@"); | |
1046 return undef; | |
1047 } | |
1048 | |
1049 return $s; | |
1050 } | |
1051 | |
1052 sub dictionary { | |
1053 join('', (map pack('N/a*', $_), qw( | |
1054 options | |
1055 head | |
1056 post | |
1057 put | |
1058 delete | |
1059 trace | |
1060 accept | |
1061 accept-charset | |
1062 accept-encoding | |
1063 accept-language | |
1064 accept-ranges | |
1065 age | |
1066 allow | |
1067 authorization | |
1068 cache-control | |
1069 connection | |
1070 content-base | |
1071 content-encoding | |
1072 content-language | |
1073 content-length | |
1074 content-location | |
1075 content-md5 | |
1076 content-range | |
1077 content-type | |
1078 date | |
1079 etag | |
1080 expect | |
1081 expires | |
1082 from | |
1083 host | |
1084 if-match | |
1085 if-modified-since | |
1086 if-none-match | |
1087 if-range | |
1088 if-unmodified-since | |
1089 last-modified | |
1090 location | |
1091 max-forwards | |
1092 pragma | |
1093 proxy-authenticate | |
1094 proxy-authorization | |
1095 range | |
1096 referer | |
1097 retry-after | |
1098 server | |
1099 te | |
1100 trailer | |
1101 transfer-encoding | |
1102 upgrade | |
1103 user-agent | |
1104 vary | |
1105 via | |
1106 warning | |
1107 www-authenticate | |
1108 method | |
1109 get | |
1110 status), "200 OK", | |
1111 qw(version HTTP/1.1 url public set-cookie keep-alive origin)), | |
1112 "100101201202205206300302303304305306307402405406407408409410", | |
1113 "411412413414415416417502504505", | |
1114 "203 Non-Authoritative Information", | |
1115 "204 No Content", | |
1116 "301 Moved Permanently", | |
1117 "400 Bad Request", | |
1118 "401 Unauthorized", | |
1119 "403 Forbidden", | |
1120 "404 Not Found", | |
1121 "500 Internal Server Error", | |
1122 "501 Not Implemented", | |
1123 "503 Service Unavailable", | |
1124 "Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec", | |
1125 " 00:00:00", | |
1126 " Mon, Tue, Wed, Thu, Fri, Sat, Sun, GMT", | |
1127 "chunked,text/html,image/png,image/jpg,image/gif,", | |
1128 "application/xml,application/xhtml+xml,text/plain,", | |
1129 "text/javascript,public", "privatemax-age=gzip,deflate,", | |
1130 "sdchcharset=utf-8charset=iso-8859-1,utf-,*,enq=0." | |
1131 ); | |
1132 } | |
1133 | |
1134 ############################################################################### | |
487
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1135 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1136 # reply with multiple (also empty) header values |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1137 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1138 sub http_daemon { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1139 my $server = IO::Socket::INET->new( |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1140 Proto => 'tcp', |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1141 LocalHost => '127.0.0.1', |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1142 LocalPort => 8083, |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1143 Listen => 5, |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1144 Reuse => 1 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1145 ) |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1146 or die "Can't create listening socket: $!\n"; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1147 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1148 local $SIG{PIPE} = 'IGNORE'; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1149 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1150 while (my $client = $server->accept()) { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1151 $client->autoflush(1); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1152 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1153 my $headers = ''; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1154 my $uri = ''; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1155 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1156 while (<$client>) { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1157 $headers .= $_; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1158 last if (/^\x0d?\x0a?$/); |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1159 } |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1160 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1161 next if $headers eq ''; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1162 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1163 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1164 if ($uri eq '/inside') { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1165 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1166 print $client <<EOF; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1167 HTTP/1.1 200 OK |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1168 Connection: close |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1169 X-Foo: val1 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1170 X-Foo: |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1171 X-Foo: val2 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1172 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1173 EOF |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1174 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1175 } elsif ($uri eq '/first') { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1176 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1177 print $client <<EOF; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1178 HTTP/1.1 200 OK |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1179 Connection: close |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1180 X-Foo: |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1181 X-Foo: val1 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1182 X-Foo: val2 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1183 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1184 EOF |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1185 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1186 } elsif ($uri eq '/last') { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1187 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1188 print $client <<EOF; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1189 HTTP/1.1 200 OK |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1190 Connection: close |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1191 X-Foo: val1 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1192 X-Foo: val2 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1193 X-Foo: |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1194 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1195 EOF |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1196 } |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1197 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1198 } continue { |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1199 close $client; |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1200 } |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1201 } |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1202 |
c5ff54b56710
Tests: SPDY tests for empty header value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
486
diff
changeset
|
1203 ############################################################################### |