annotate spdy.t @ 550:a04b8b9537cd

Tests: adjusted resolver test timeout. Gave more change for resend before resolver_timeout.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 20 Apr 2015 16:00:49 +0300
parents 42810c40ebb8
children 907e89fba9c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for SPDY protocol version 3.1.
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 BEGIN { use FindBin; chdir($FindBin::Bin); }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 use lib 'lib';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 use Test::Nginx;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 ###############################################################################
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 select STDERR; $| = 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 select STDOUT; $| = 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 eval {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 require Compress::Raw::Zlib;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 Compress::Raw::Zlib->Z_OK;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 Compress::Raw::Zlib->Z_SYNC_FLUSH;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 Compress::Raw::Zlib->Z_NO_COMPRESSION;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 plan(skip_all => 'Compress::Raw::Zlib not installed') if $@;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 plan(skip_all => 'win32') if $^O eq 'MSWin32';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 %%TEST_GLOBALS%%
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 daemon off;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 events {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 http {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 %%TEST_GLOBALS_HTTP%%
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 limit_conn_zone $binary_remote_addr zone=conn:1m;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 server {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 listen 127.0.0.1:8080 spdy;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 server_name localhost;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 location /s {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 add_header X-Header X-Foo;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 return 200 'body';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 location /spdy {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 return 200 $spdy;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 location /prio {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 return 200 $spdy_request_priority;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 location /chunk_size {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 spdy_chunk_size 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 return 200 'body';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 location /redirect {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 error_page 405 /s;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 return 405;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 location /proxy {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 add_header X-Body "$request_body";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 proxy_pass http://127.0.0.1:8081/;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 proxy_cache NAME;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 proxy_cache_valid 1m;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 location /t3.html {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 limit_conn conn 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 EOF
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 # file size is slightly beyond initial window size: 2**16 + 80 bytes
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 $t->write_file('t1.html',
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202)));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 $t->write_file('t2.html', 'SEE-THIS');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 $t->write_file('t3.html', 'SEE-THIS');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 my %cframe = (
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 2 => \&syn_reply,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 3 => \&rst_stream,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 4 => \&settings,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 6 => \&ping,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 7 => \&goaway,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 9 => \&window_update
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 ###############################################################################
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 # PING
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 my $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 my ($frame) = grep { $_->{type} eq "PING" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 ok($frame, 'PING frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 is($frame->{value}, 0x12345678, 'PING payload');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 # GET
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 my $sid1 = spdy_stream($sess, { path => '/s' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 ok($frame, 'SYN_REPLAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 is($frame->{sid}, $sid1, 'SYN_REPLAY stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 ok($frame, 'DATA frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 is($frame->{length}, length 'body', 'DATA length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165 is($frame->{data}, 'body', 'DATA payload');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 # GET in new SPDY stream in same session
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 my $sid2 = spdy_stream($sess, { path => '/s' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178 ok($frame, 'DATA frame 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
179 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
180 is($frame->{length}, length 'body', 'DATA length 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
181 is($frame->{data}, 'body', 'DATA payload 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
182
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
183 # HEAD
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
184
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
185 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
186 $sid1 = spdy_stream($sess, { path => '/s', method => 'HEAD' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
187 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
188
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
190 is($frame->{sid}, $sid1, 'SYN_REPLAY stream HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
191 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
193
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
194 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195 is($frame, undef, 'HEAD no body');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
208 # request header
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
209
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
210 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
211 $sid1 = spdy_stream($sess, { path => '/t1.html',
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
212 headers => { "range" => "bytes=10-19" }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
213 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217 is($frame->{headers}->{':status'}, 206, 'SYN_REPLAY status range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
218
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
219 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220 is($frame->{length}, 10, 'DATA length range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
221 is($frame->{data}, '002XXXX000', 'DATA payload range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
286 # $spdy
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
287
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
288 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
289 $sid1 = spdy_stream($sess, { path => '/spdy' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
290 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
291
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
292 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
293 is($frame->{data}, '3.1', 'spdy variable');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
294
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
295 # spdy_chunk_size=1
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
296
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
297 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
298 $sid1 = spdy_stream($sess, { path => '/chunk_size' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
299 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
300
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
301 my @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
302 is(@data, 4, 'chunk_size body chunks');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
303 is($data[0]->{data}, 'b', 'chunk_size body 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
304 is($data[1]->{data}, 'o', 'chunk_size body 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
305 is($data[2]->{data}, 'd', 'chunk_size body 3');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 is($data[3]->{data}, 'y', 'chunk_size body 4');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
307
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
308 # redirect
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311 $sid1 = spdy_stream($sess, { path => '/redirect' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
313
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
314 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315 is($frame->{headers}->{':status'}, 405, 'SYN_REPLAY status with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
316
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
317 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
318 ok($frame, 'DATA frame with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
319 is($frame->{data}, 'body', 'DATA payload with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
330 # ensure that HEAD-like requests, i.e., without response body, do not lead to
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
331 # client connection close due to cache filling up with upstream response body
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
336
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
339 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), 'proxy cache headers only');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
340
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
341 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
354 # simple proxy cache test
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
355
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
356 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
357 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
358 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
359
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
360 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
361 is($frame->{headers}->{':status'}, '200 OK', 'proxy cache unconditional');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
362
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
365 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
366 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
367
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
368 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
369 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
370
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
371 # request body (uses proxied response)
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
372
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
373 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
374 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html', body => 'TEST' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
375 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
376
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
377 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
378 is($frame->{headers}->{'x-body'}, 'TEST', 'request body');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
379
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
380 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
381 is($frame->{length}, length 'SEE-THIS', 'proxied response length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
382 is($frame->{data}, 'SEE-THIS', 'proxied response');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
383
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
384 # WINDOW_UPDATE (client side)
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
385
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
386 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
389
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
390 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
391 my $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
392 is($sum, 2**16, 'iws - stream blocked on initial window size');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
393
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
396
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
397 ($frame) = grep { $_->{type} eq "PING" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
398 ok($frame, 'iws - PING not blocked');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
399
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
400 spdy_window($sess, 2**16, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
401 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
402 is(@$frames, 0, 'iws - updated stream window');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
403
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
404 spdy_window($sess, 2**16);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
405 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
406
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
407 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
408 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
409 is($sum, 80, 'iws - updated connection window');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
410
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
411 # SETTINGS (initial window size, client side)
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
412
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
413 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
414 spdy_settings($sess, 7 => 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
415 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
416
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
417 $sid1 = spdy_stream($sess, { path => '/t1.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
418 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
419
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
420 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
421 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
422 is($sum, 2**16 + 80, 'increased initial window size');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
423
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
424 # probe for negative available space in a flow control window
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
425
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
426 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
429
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
430 spdy_window($sess, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
431 spdy_settings($sess, 7 => 42);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
432 spdy_window($sess, 1024, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
433
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
434 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
435 is(@$frames, 0, 'negative window - no data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
436
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
437 spdy_window($sess, 2**16 - 42 - 1024, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
438 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
439 is(@$frames, 0, 'zero window - no data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
440
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
443 is(@$frames, 1, 'positive window - data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
444 is(@$frames[0]->{length}, 1, 'positive window - data length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
445
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
446 # stream multiplexing
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
447
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
448 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
451
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
452 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
453 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
454 is($sum, 2**16, 'multiple - stream1 data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
455
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
456 $sid2 = spdy_stream($sess, { path => '/t1.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
457 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
458
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
459 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
460 is(@data, 0, 'multiple - stream2 no data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
461
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
462 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
463 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
464 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
465
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
466 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
467 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
468 { sid => $sid2, fin => 1 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
469 ]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
470
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
471 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
472 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
473 is($sum, 80, 'multiple - stream1 remain data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
474
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
475 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
476 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
477 is($sum, 2**16 + 80, 'multiple - stream2 full data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
478
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
479 # request priority parsing in $spdy_request_priority
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
480
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
481 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
482 $sid1 = spdy_stream($sess, { path => '/prio', prio => 0 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
483 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
484
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
485 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
486 is($frame->{data}, 0, 'priority 0');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
487
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
488 $sid1 = spdy_stream($sess, { path => '/prio', prio => 1 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
489 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
490
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
491 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
492 is($frame->{data}, 1, 'priority 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
493
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
494 $sid1 = spdy_stream($sess, { path => '/prio', prio => 7 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
495 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
496
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
497 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
498 is($frame->{data}, 7, 'priority 7');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
499
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
500 # stream muliplexing + priority
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
501
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
502 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
508
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
509 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
510 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
511 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
512
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
513 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
514 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
515 { sid => $sid2, fin => 1 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
516 ]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
517
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
518 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
519 is(join (' ', map { $_->{sid} } @data), "$sid2 $sid1", 'multiple priority 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
520
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
521 # and vice versa
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
522
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
523 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
529
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
530 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
531 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
532 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
533
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
534 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
535 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
536 { sid => $sid2, fin => 1 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
537 ]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
538
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
539 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
540 is(join (' ', map { $_->{sid} } @data), "$sid1 $sid2", 'multiple priority 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
541
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
542 # limit_conn
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
543
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
544 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
549
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
550 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
551 is($frame->{headers}->{':status'}, 200, 'conn_limit 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
556 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
557 is($frame->{headers}->{':status'}, 503, 'conn_limit 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
566 # limit_conn + client's RST_STREAM
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
567
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
568 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
573 spdy_rst($sess, $sid1, 5);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
574
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
575 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
576 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
581 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
582 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
583
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
584 # GOAWAY on SYN_STREAM with even StreamID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
585
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
586 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
587 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
588
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
589 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
590 spdy_stream($sess, { path => '/s' }, 2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
591 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
592
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
593 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
594 ok($frame, 'even stream - GOAWAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
595 is($frame->{code}, 1, 'even stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
596 is($frame->{sid}, 0, 'even stream - last used stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
597
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
598 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
599
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
600 # GOAWAY on SYN_STREAM with backward StreamID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
601
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
602 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
603 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
604
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
605 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
606 $sid1 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
607 spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
608
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
609 $sid2 = spdy_stream($sess, { path => '/s' }, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
610 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
611
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
612 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
613 ok($frame, 'backward stream - GOAWAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
614 is($frame->{code}, 1, 'backward stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
615 is($frame->{sid}, $sid1, 'backward stream - last used stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
616
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
617 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
618
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
619 # RST_STREAM on the second SYN_STREAM with same StreamID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
620
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
621 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
622 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
623
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
624 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
625 $sid1 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
626 spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
627 $sid2 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
628 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
629
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
630 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
631 ok($frame, 'dup stream - RST_STREAM frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
632 is($frame->{code}, 1, 'dup stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
633 is($frame->{sid}, $sid1, 'dup stream - stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
634
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
635 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
636
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
637 # awkward protocol version
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
638
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
639 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
640 $sid1 = spdy_stream($sess, { path => '/s', version => 'HTTP/1.10' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
641 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
642
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
643 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
644 is($frame->{headers}->{':status'}, 200, 'awkward version');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
645
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
646 # missing mandatory request header
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
647
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
648 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
649 $sid1 = spdy_stream($sess, { path => '/s', version => '' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
650 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
651
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
652 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
653 is($frame->{headers}->{':status'}, 400, 'incomplete headers');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
654
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
655 # GOAWAY before closing a connection by server
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
656
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
657 $t->stop();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
658
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
659 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
660 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
661
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
662 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
663
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
664 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
665 ok($frame, 'GOAWAY on connection close');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
666
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
667 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
668
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
669 ###############################################################################
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
670
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
671 sub spdy_ping {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
672 my ($sess, $payload) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
673
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
674 raw_write($sess->{socket}, pack("N3", 0x80030006, 0x4, $payload));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
675 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
676
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
677 sub spdy_rst {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
678 my ($sess, $sid, $error) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
679
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
680 raw_write($sess->{socket}, pack("N4", 0x80030003, 0x8, $sid, $error));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
681 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
682
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
683 sub spdy_window {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
684 my ($sess, $win, $stream) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
685
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
686 $stream = 0 unless defined $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
687 raw_write($sess->{socket}, pack("N4", 0x80030009, 8, $stream, $win));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
688 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
689
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
690 sub spdy_settings {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
691 my ($sess, %extra) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
692
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
693 my $cnt = keys %extra;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
694 my $len = 4 + 8 * $cnt;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
695
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
696 my $buf = pack "N3", 0x80030004, $len, $cnt;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
697 $buf .= join '', map { pack "N2", $_, $extra{$_} } keys %extra;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
698 raw_write($sess->{socket}, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
699 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
700
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
701 sub spdy_read {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
710 again:
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
711 alarm(1);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
732 return \@got;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
733 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
734
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
735 sub test_fin {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
763 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
764
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
769
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
770 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
771 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
772 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
773 $frame{sid} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
774
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
775 my $flags = unpack "\@$skip B8", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
776 $frame{fin} = substr($flags, 7, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
777
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
778 my $length = hex (unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
779 $frame{length} = $length;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
780
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
781 $frame{data} = substr($buf, $skip, $length);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
782 $frame{type} = "DATA";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
783 return \%frame;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
784 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
785
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
786 sub spdy_stream {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
787 my ($ctx, $uri, $stream) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
788 my ($input, $output, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
789 my ($d, $status);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
790
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
791 my $host = $uri->{host} || '127.0.0.1:8080';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
792 my $method = $uri->{method} || 'GET';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
793 my $headers = $uri->{headers} || {};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
794 my $body = $uri->{body};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
795 my $prio = defined $uri->{prio} ? $uri->{prio} : 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
796 my $version = defined $uri->{version} ? $uri->{version} : "HTTP/1.1";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
797
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
798 if ($stream) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
799 $ctx->{last_stream} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
800 } else {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
801 $ctx->{last_stream} += 2;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
802 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
803
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
804 $buf = pack("NC", 0x80030001, not $body);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
805 $buf .= pack("xxx"); # Length stub
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
806 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
807 $buf .= pack("N", 0); # Assoc. Stream-ID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
808 $buf .= pack("n", $prio << 13);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
809
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
810 my $ent = 4 + keys %{$headers};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
811 $ent++ if $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
812 $ent++ if $version;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
813
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
814 $input = pack("N", $ent);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
815 $input .= hpack(":host", $host);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
816 $input .= hpack(":method", $method);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
817 $input .= hpack(":path", $uri->{path});
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
818 $input .= hpack(":scheme", "http");
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
819 if ($version) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
820 $input .= hpack(":version", $version);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
821 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
822 if ($body) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
823 $input .= hpack("content-length", length $body);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
824 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
825 $input .= join '', map { hpack($_, $headers->{$_}) } keys %{$headers};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
826
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
827 $d = $ctx->{zlib}->{d};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
828 $status = $d->deflate($input => \my $start);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
829 $status == Compress::Raw::Zlib->Z_OK or fail "deflate failed";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
830 $status = $d->flush(\my $tail => Compress::Raw::Zlib->Z_SYNC_FLUSH);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
831 $status == Compress::Raw::Zlib->Z_OK or fail "flush failed";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
832 $output = $start . $tail;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
837 $buf .= $output;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
838
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
839 if (defined $body) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
840 $buf .= pack "NCxn", $ctx->{last_stream}, 0x01, length $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
841 $buf .= $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
842 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
843
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
844 raw_write($ctx->{socket}, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
845 return $ctx->{last_stream};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
846 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
847
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
850 my ($i, $status);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
853
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
854 my $flags = unpack "\@$skip B8", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
855 $payload{fin} = substr($flags, 7, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
856
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
857 my $length = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
858 $payload{length} = $length;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
859 $payload{type} = 'SYN_REPLY';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
860
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
861 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
862 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
863 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
864 $payload{sid} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
865
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
866 my $input = substr($buf, $skip, $length - 4);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
867 $i = $ctx->{zlib}->{i};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
868
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
869 $status = $i->inflate($input => \my $out);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
870 fail "Failed: $status" unless $status == Compress::Raw::Zlib->Z_OK;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
871 $payload{headers} = hunpack($out);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
872 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
873 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
874
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
879
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
880 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
881 $payload{type} = 'RST_STREAM';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
882 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
883 $payload{code} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
884 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
885 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
886
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
891
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
892 $payload{flags} = unpack "\@$skip H", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
893 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
894 $payload{type} = 'SETTINGS';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
895
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
896 my $nent = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
897 for (1 .. $nent) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
898 my $flags = hex unpack "\@$skip H2", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
899 my $id = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
900 $payload{$id}{flags} = $flags;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
901 $payload{$id}{value} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
902 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
903 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
904 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
905
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
910
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
911 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
912 $payload{type} = 'PING';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
913 $payload{value} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
914 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
915 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
916
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
921
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
922 $payload{length} = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
923 $payload{type} = 'GOAWAY';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
924 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
925 $payload{code} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
926 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
927 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
928
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
933
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
934 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
935 $payload{type} = 'WINDOW_UPDATE';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
936
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
937 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
938 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
939 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
940 $payload{sid} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
941
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
942 my $value = unpack "\@$skip B32", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
943 substr($value, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
944 $payload{wdelta} = unpack("N", pack("B32", $value));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
945 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
946 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
947
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
948 sub hpack {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
949 my ($name, $value) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
950
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
951 pack("N", length($name)) . $name . pack("N", length($value)) . $value;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
952 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
953
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
954 sub hunpack {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
955 my ($data) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
956 my %headers;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
957 my $skip = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
958
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
959 my $nent = unpack "\@$skip N", $data; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
960 for (1 .. $nent) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
961 my $len = unpack("\@$skip N", $data); $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
962 my $name = unpack("\@$skip A$len", $data); $skip += $len;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
963
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
964 $len = unpack("\@$skip N", $data); $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
967
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
968 $headers{$name} = $value;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
969 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
970 return \%headers;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
971 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
972
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
983 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
984
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
985 sub raw_write {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
986 my ($s, $message) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
987
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
988 local $SIG{PIPE} = 'IGNORE';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
989
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
990 while (IO::Select->new($s)->can_write(0.4)) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
991 log_out($message);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
992 my $n = $s->syswrite($message);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
993 last unless $n;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
994 $message = substr($message, $n);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
995 last unless length $message;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
996 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
997 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
998
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1002
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1003 ($d, $status) = Compress::Raw::Zlib::Deflate->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1004 -WindowBits => 12,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1005 -Dictionary => dictionary(),
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1006 -Level => Compress::Raw::Zlib->Z_NO_COMPRESSION
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1007 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1008 fail "Zlib failure: $status" unless $d;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1009
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1010 ($i, $status) = Compress::Raw::Zlib::Inflate->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1011 -WindowBits => Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1012 -Dictionary => dictionary()
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1013 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1014 fail "Zlib failure: $status" unless $i;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1024 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1025
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1028 my $s;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1032 eval {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1033 local $SIG{ALRM} = sub { die "timeout\n" };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1034 local $SIG{PIPE} = sub { die "sigpipe\n" };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1035 alarm(2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1036 $s = IO::Socket::INET->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1039 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1040 alarm(0);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1041 };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1042 alarm(0);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1043
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1044 if ($@) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1045 log_in("died: $@");
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1046 return undef;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1047 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1048
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1049 return $s;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1050 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1051
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1052 sub dictionary {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1053 join('', (map pack('N/a*', $_), qw(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1054 options
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1055 head
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1056 post
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1057 put
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1058 delete
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1059 trace
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1060 accept
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1061 accept-charset
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1062 accept-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1063 accept-language
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1064 accept-ranges
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1065 age
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1066 allow
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1067 authorization
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1068 cache-control
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1069 connection
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1070 content-base
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1071 content-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1072 content-language
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1073 content-length
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1074 content-location
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1075 content-md5
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1076 content-range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1077 content-type
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1078 date
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1079 etag
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1080 expect
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1081 expires
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1082 from
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1083 host
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1084 if-match
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1085 if-modified-since
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1086 if-none-match
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1087 if-range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1088 if-unmodified-since
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1089 last-modified
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1090 location
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1091 max-forwards
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1092 pragma
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1093 proxy-authenticate
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1094 proxy-authorization
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1095 range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1096 referer
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1097 retry-after
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1098 server
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1099 te
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1100 trailer
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1101 transfer-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1102 upgrade
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1103 user-agent
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1104 vary
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1105 via
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1106 warning
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1107 www-authenticate
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1108 method
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1109 get
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1110 status), "200 OK",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1111 qw(version HTTP/1.1 url public set-cookie keep-alive origin)),
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1112 "100101201202205206300302303304305306307402405406407408409410",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1113 "411412413414415416417502504505",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1114 "203 Non-Authoritative Information",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1115 "204 No Content",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1116 "301 Moved Permanently",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1117 "400 Bad Request",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1118 "401 Unauthorized",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1119 "403 Forbidden",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1120 "404 Not Found",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1121 "500 Internal Server Error",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1122 "501 Not Implemented",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1123 "503 Service Unavailable",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1124 "Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1125 " 00:00:00",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1126 " Mon, Tue, Wed, Thu, Fri, Sat, Sun, GMT",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1127 "chunked,text/html,image/png,image/jpg,image/gif,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1128 "application/xml,application/xhtml+xml,text/plain,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1129 "text/javascript,public", "privatemax-age=gzip,deflate,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1130 "sdchcharset=utf-8charset=iso-8859-1,utf-,*,enq=0."
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1131 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1132 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1133
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
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 ###############################################################################