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