annotate spdy.t @ 427:daea9cf92c14

Tests: added proxy protocol tests over SPDY.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 04 Jul 2014 12:37:14 +0400
parents 7cb6af00afdd
children e95c3340d94a
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
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
41 $t->plan(74)->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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:10m;
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 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 location /t3.html {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 limit_conn conn 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 EOF
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 $t->run();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 # 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
103
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 $t->write_file('t1.html',
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 join('', map { sprintf "X%04dXXX", $_ } (1 .. 8202)));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 $t->write_file('t2.html', 'SEE-THIS');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 $t->write_file('t3.html', 'SEE-THIS');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 my %cframe = (
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 2 => \&syn_reply,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 3 => \&rst_stream,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 4 => \&settings,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 6 => \&ping,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 7 => \&goaway,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 9 => \&window_update
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 ###############################################################################
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 # PING
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 my $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 spdy_ping($sess, 0x12345678);
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
125 my $frames = spdy_read($sess, all => [{ type => 'PING' }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 my ($frame) = grep { $_->{type} eq "PING" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 ok($frame, 'PING frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 is($frame->{value}, 0x12345678, 'PING payload');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 # GET
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 my $sid1 = spdy_stream($sess, { path => '/s' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 ok($frame, 'SYN_REPLAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 is($frame->{sid}, $sid1, 'SYN_REPLAY stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 ok($frame, 'DATA frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 is($frame->{length}, length 'body', 'DATA length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146 is($frame->{data}, 'body', 'DATA payload');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 # GET in new SPDY stream in same session
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 my $sid2 = spdy_stream($sess, { path => '/s' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 ok($frame, 'DATA frame 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 is($frame->{sid}, $sid2, 'SYN_REPLAY stream 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 is($frame->{length}, length 'body', 'DATA length 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162 is($frame->{data}, 'body', 'DATA payload 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 # HEAD
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 $sid1 = spdy_stream($sess, { path => '/s', method => 'HEAD' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171 is($frame->{sid}, $sid1, 'SYN_REPLAY stream HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 is($frame->{headers}->{':status'}, 200, 'SYN_REPLAY status HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 is($frame->{headers}->{'x-header'}, 'X-Foo', 'SYN_REPLAY header HEAD');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 is($frame, undef, 'HEAD no body');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
178 # GET with PROXY protocol
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
179
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
180 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
181 $sess = new_session(8082, proxy => $proxy);
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
182 $sid1 = spdy_stream($sess, { path => '/pp' });
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
183 $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
184
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
185 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
186 ok($frame, 'PROXY SYN_REPLAY frame');
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
187 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
188
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
189 # request header
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
190
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
191 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
192 $sid1 = spdy_stream($sess, { path => '/t1.html',
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
193 headers => { "range" => "bytes=10-19" }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
194 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
195 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
196
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
197 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
198 is($frame->{headers}->{':status'}, 206, 'SYN_REPLAY status range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
199
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
200 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
201 is($frame->{length}, 10, 'DATA length range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
202 is($frame->{data}, '002XXXX000', 'DATA payload range');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
203
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
204 # $spdy
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
205
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
206 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
207 $sid1 = spdy_stream($sess, { path => '/spdy' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
208 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
211 is($frame->{data}, '3.1', 'spdy variable');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
212
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
213 # spdy_chunk_size=1
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216 $sid1 = spdy_stream($sess, { path => '/chunk_size' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 my @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220 is(@data, 4, 'chunk_size body chunks');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
221 is($data[0]->{data}, 'b', 'chunk_size body 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
222 is($data[1]->{data}, 'o', 'chunk_size body 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
223 is($data[2]->{data}, 'd', 'chunk_size body 3');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
224 is($data[3]->{data}, 'y', 'chunk_size body 4');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
225
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
226 # redirect
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
227
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
228 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
229 $sid1 = spdy_stream($sess, { path => '/redirect' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
230 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
231
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
232 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
233 is($frame->{headers}->{':status'}, 405, 'SYN_REPLAY status with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
234
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
235 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
236 ok($frame, 'DATA frame with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
237 is($frame->{data}, 'body', 'DATA payload with redirect');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
238
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
239 # 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
240 # 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
241
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
242 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
243 local $TODO = 'premature client connection close';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
244
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
245 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
246 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html', method => 'HEAD' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
247 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
248
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
249 $sid2 = spdy_stream($sess, { path => '/' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
250 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
251 ok(grep ({ $_->{type} eq "SYN_REPLY" } @$frames), 'proxy cache headers only');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
252
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
253 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
254
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
255 # simple proxy cache test
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
256
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
257 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
258 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
259 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
260
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
261 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
262 is($frame->{headers}->{':status'}, '200 OK', 'proxy cache unconditional');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
263
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
264 $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
265 headers => { "if-none-match" => $frame->{headers}->{'etag'} }
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
266 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
267 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
268
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
269 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
270 is($frame->{headers}->{':status'}, 304, 'proxy cache conditional');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
271
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
272 # request body (uses proxied response)
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
273
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
274 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
275 $sid1 = spdy_stream($sess, { path => '/proxy/t2.html', body => 'TEST' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
276 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
277
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
278 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
279 is($frame->{headers}->{'x-body'}, 'TEST', 'request body');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
280
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
281 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
282 is($frame->{length}, length 'SEE-THIS', 'proxied response length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
283 is($frame->{data}, 'SEE-THIS', 'proxied response');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
284
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
285 # WINDOW_UPDATE (client side)
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
286
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
287 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
288 $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
289 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
290
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
291 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
292 my $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
293 is($sum, 2**16, 'iws - stream blocked on initial window size');
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_ping($sess, 0xf00ff00f);
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
296 $frames = spdy_read($sess, all => [{ type => 'PING' }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
297
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
298 ($frame) = grep { $_->{type} eq "PING" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
299 ok($frame, 'iws - PING not blocked');
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 spdy_window($sess, 2**16, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
302 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
303 is(@$frames, 0, 'iws - updated stream window');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
304
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
305 spdy_window($sess, 2**16);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310 is($sum, 80, 'iws - updated connection window');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312 # SETTINGS (initial window size, client side)
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 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315 spdy_settings($sess, 7 => 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
316 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
317
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
318 $sid1 = spdy_stream($sess, { path => '/t1.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
319 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
320
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
321 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
322 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
323 is($sum, 2**16 + 80, 'increased initial window size');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
324
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
325 # probe for negative available space in a flow control window
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
326
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
327 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
328 $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
329 spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
330
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
331 spdy_window($sess, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332 spdy_settings($sess, 7 => 42);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
333 spdy_window($sess, 1024, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
334
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
335 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
336 is(@$frames, 0, 'negative window - no data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
337
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
338 spdy_window($sess, 2**16 - 42 - 1024, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
339 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
340 is(@$frames, 0, 'zero window - no data');
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 spdy_window($sess, 1, $sid1);
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
343 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 1 }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
344 is(@$frames, 1, 'positive window - data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
345 is(@$frames[0]->{length}, 1, 'positive window - data length');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
346
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
347 # stream multiplexing
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
348
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
349 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
350 $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
351 $frames = spdy_read($sess, all => [{ sid => $sid1, length => 2**16 }]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
352
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
353 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
354 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
355 is($sum, 2**16, 'multiple - stream1 data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
356
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
357 $sid2 = spdy_stream($sess, { path => '/t1.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
358 $frames = spdy_read($sess, all => [{ sid => $sid2, fin => 0 }]);
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 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
361 is(@data, 0, 'multiple - stream2 no data');
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 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
364 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
365 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
366
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
367 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
368 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
369 { sid => $sid2, fin => 1 }
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
372 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
373 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
374 is($sum, 80, 'multiple - stream1 remain data');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
375
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
376 @data = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
377 $sum = eval join '+', map { $_->{length} } @data;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
378 is($sum, 2**16 + 80, 'multiple - stream2 full data');
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 # request priority parsing in $spdy_request_priority
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
381
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
382 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
383 $sid1 = spdy_stream($sess, { path => '/prio', prio => 0 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
384 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
387 is($frame->{data}, 0, 'priority 0');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
388
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
389 $sid1 = spdy_stream($sess, { path => '/prio', prio => 1 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
390 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
391
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
392 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
393 is($frame->{data}, 1, 'priority 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
394
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
395 $sid1 = spdy_stream($sess, { path => '/prio', prio => 7 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
396 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
397
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
398 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
399 is($frame->{data}, 7, 'priority 7');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
400
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
401 # stream muliplexing + priority
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
402
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
403 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
404 $sid1 = spdy_stream($sess, { path => '/t1.html', prio => 7 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
405 $sid2 = spdy_stream($sess, { path => '/t2.html', prio => 0 });
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
406 spdy_read($sess, all => [
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
407 { sid => $sid1, length => 2**16 },
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
408 { sid => $sid2, fin => 0 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
409 ]);
374
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 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
412 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
413 spdy_window($sess, 2**17);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
414
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
415 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
416 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
417 { sid => $sid2, fin => 1 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
418 ]);
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 is(join (' ', map { $_->{sid} } @data), "$sid2 $sid1", 'multiple priority 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
422
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
423 # and vice versa
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
424
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
425 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
426 $sid1 = spdy_stream($sess, { path => '/t1.html', prio => 0 });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
427 $sid2 = spdy_stream($sess, { path => '/t2.html', prio => 7 });
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
428 spdy_read($sess, all => [
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
429 { sid => $sid1, length => 2**16 },
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
430 { sid => $sid2, fin => 0 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
431 ]);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
432
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
433 spdy_window($sess, 2**17, $sid1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
434 spdy_window($sess, 2**17, $sid2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
435 spdy_window($sess, 2**17);
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 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
438 { sid => $sid1, fin => 1 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
439 { sid => $sid2, fin => 1 }
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
442 @data = grep { $_->{type} eq "DATA" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
443 is(join (' ', map { $_->{sid} } @data), "$sid1 $sid2", 'multiple priority 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
444
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
445 # limit_conn
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
446
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
447 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
448 spdy_settings($sess, 7 => 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
449 $sid1 = spdy_stream($sess, { path => '/t3.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
450 $sid2 = spdy_stream($sess, { path => '/t3.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
451 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
452 { sid => $sid1, fin => 0 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
453 { sid => $sid2, fin => 0 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
454 ]);
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 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
457 is($frame->{headers}->{':status'}, 200, 'conn_limit 1');
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 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
460 is($frame->{headers}->{':status'}, 503, 'conn_limit 2');
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 # limit_conn + client's RST_STREAM
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
463
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
464 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
465 spdy_settings($sess, 7 => 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
466 $sid1 = spdy_stream($sess, { path => '/t3.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
467 spdy_rst($sess, $sid1, 5);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
468 $sid2 = spdy_stream($sess, { path => '/t3.html' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
469 $frames = spdy_read($sess, all => [
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
470 { sid => $sid1, fin => 0 },
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
471 { sid => $sid2, fin => 0 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
472 ]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
473
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
474 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid1 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
475 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
476
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
477 ($frame) = grep { $_->{type} eq "SYN_REPLY" && $_->{sid} == $sid2 } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
478 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
479
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
480 # GOAWAY on SYN_STREAM with even StreamID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
481
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
482 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
483 local $TODO = 'not yet';
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 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
486 spdy_stream($sess, { path => '/s' }, 2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
487 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
488
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
489 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
490 ok($frame, 'even stream - GOAWAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
491 is($frame->{code}, 1, 'even stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
492 is($frame->{sid}, 0, 'even stream - last used stream');
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 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
495
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
496 # GOAWAY on SYN_STREAM with backward StreamID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
497
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
498 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
499 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
500
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
501 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
502 $sid1 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
503 spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
504
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
505 $sid2 = spdy_stream($sess, { path => '/s' }, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
506 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
507
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
508 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
509 ok($frame, 'backward stream - GOAWAY frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
510 is($frame->{code}, 1, 'backward stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
511 is($frame->{sid}, $sid1, 'backward stream - last used stream');
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 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
514
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
515 # RST_STREAM on the second SYN_STREAM with same StreamID
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 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
518 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
519
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
520 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
521 $sid1 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
522 spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
523 $sid2 = spdy_stream($sess, { path => '/s' }, 3);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
524 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
525
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
526 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
527 ok($frame, 'dup stream - RST_STREAM frame');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
528 is($frame->{code}, 1, 'dup stream - error code');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
529 is($frame->{sid}, $sid1, 'dup stream - stream');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
530
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
531 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
532
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
533 # awkward protocol version
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
534
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
535 $sess = new_session();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
536 $sid1 = spdy_stream($sess, { path => '/s', version => 'HTTP/1.10' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
537 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
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 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
540 is($frame->{headers}->{':status'}, 200, 'awkward version');
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 # missing mandatory request header
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 $sid1 = spdy_stream($sess, { path => '/s', version => '' });
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
546 $frames = spdy_read($sess, all => [{ sid => $sid1, fin => 1 }]);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
547
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
548 ($frame) = grep { $_->{type} eq "SYN_REPLY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
549 is($frame->{headers}->{':status'}, 400, 'incomplete headers');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
550
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
551 # GOAWAY before closing a connection by server
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
552
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
553 $t->stop();
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
554
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
555 TODO: {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
556 local $TODO = 'not yet';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
557
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
558 $frames = spdy_read($sess);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
559
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
560 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
561 ok($frame, 'GOAWAY on connection close');
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
562
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
563 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
564
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
565 ###############################################################################
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
566
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
567 sub spdy_ping {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
568 my ($sess, $payload) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
569
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
570 raw_write($sess->{socket}, pack("N3", 0x80030006, 0x4, $payload));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
571 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
572
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
573 sub spdy_rst {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
574 my ($sess, $sid, $error) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
575
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
576 raw_write($sess->{socket}, pack("N4", 0x80030003, 0x8, $sid, $error));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
577 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
578
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
579 sub spdy_window {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
580 my ($sess, $win, $stream) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
581
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
582 $stream = 0 unless defined $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
583 raw_write($sess->{socket}, pack("N4", 0x80030009, 8, $stream, $win));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
584 }
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 sub spdy_settings {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
587 my ($sess, %extra) = @_;
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 my $cnt = keys %extra;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
590 my $len = 4 + 8 * $cnt;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
591
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
592 my $buf = pack "N3", 0x80030004, $len, $cnt;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
593 $buf .= join '', map { pack "N2", $_, $extra{$_} } keys %extra;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
594 raw_write($sess->{socket}, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
595 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
596
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
597 sub spdy_read {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
598 my ($sess, %extra) = @_;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
599 my ($length, @got);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
600 my $s = $sess->{socket};
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
601 my $buf = '';
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
602
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
603 eval {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
604 local $SIG{ALRM} = sub { die "timeout\n" };
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
605 local $SIG{PIPE} = sub { die "sigpipe\n" };
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
606 again:
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
607 alarm(1);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
608
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
609 $buf = raw_read($s, $buf, 8);
379
f42de3a9fd74 Tests: avoid uninitialized warnings in spdy.t.
Maxim Dounin <mdounin@mdounin.ru>
parents: 377
diff changeset
610
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
611 my $type = unpack("B", $buf);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
612 $length = 8 + hex unpack("x5 H6", $buf);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
613 $buf = raw_read($s, $buf, $length);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
614
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
615 if ($type == 0) {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
616 push @got, dframe($buf);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
617
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
618 } else {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
619 my $ctype = unpack("x2 n", $buf);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
620 push @got, $cframe{$ctype}($sess, $buf);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
621 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
622 $buf = substr($buf, $length);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
623
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
624 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
625 alarm(0);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
626 };
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
627 alarm(0);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
628 return \@got;
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
631 sub test_fin {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
632 my ($frame, $all) = @_;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
633 my @test = @{$all};
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
634
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
635 # wait for the specified DATA length
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
636
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
637 for (@test) {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
638 if ($_->{length} && $frame->{type} eq 'DATA') {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
639 # check also for StreamID if needed
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
640
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
641 if (!$_->{sid} || $_->{sid} == $frame->{sid}) {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
642 $_->{length} -= $frame->{length};
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
643 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
644 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
645 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
646 @test = grep { !(defined $_->{length} && $_->{length} == 0) } @test;
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
647
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
648 # wait for the fin flag
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
649
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
650 @test = grep { !(defined $_->{fin}
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
651 && $_->{sid} == $frame->{sid} && $_->{fin} == $frame->{fin})
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
652 } @test if defined $frame->{fin};
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
653
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
654 # wait for the specified frame
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
655
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
656 @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
657
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
658 @{$all} = @test;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
659 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
660
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
661 sub dframe {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
662 my ($buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
663 my %frame;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
664 my $skip = 0;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
665
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
666 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
667 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
668 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
669 $frame{sid} = $stream;
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 my $flags = unpack "\@$skip B8", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
672 $frame{fin} = substr($flags, 7, 1);
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 my $length = hex (unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
675 $frame{length} = $length;
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 $frame{data} = substr($buf, $skip, $length);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
678 $frame{type} = "DATA";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
679 return \%frame;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
680 }
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 sub spdy_stream {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
683 my ($ctx, $uri, $stream) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
684 my ($input, $output, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
685 my ($d, $status);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
686
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
687 my $host = $uri->{host} || '127.0.0.1:8080';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
688 my $method = $uri->{method} || 'GET';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
689 my $headers = $uri->{headers} || {};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
690 my $body = $uri->{body};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
691 my $prio = defined $uri->{prio} ? $uri->{prio} : 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
692 my $version = defined $uri->{version} ? $uri->{version} : "HTTP/1.1";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
693
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
694 if ($stream) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
695 $ctx->{last_stream} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
696 } else {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
697 $ctx->{last_stream} += 2;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
698 }
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 $buf = pack("NC", 0x80030001, not $body);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
701 $buf .= pack("xxx"); # Length stub
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
702 $buf .= pack("N", $ctx->{last_stream}); # Stream-ID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
703 $buf .= pack("N", 0); # Assoc. Stream-ID
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
704 $buf .= pack("n", $prio << 13);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
705
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
706 my $ent = 4 + keys %{$headers};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
707 $ent++ if $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
708 $ent++ if $version;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
709
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
710 $input = pack("N", $ent);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
711 $input .= hpack(":host", $host);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
712 $input .= hpack(":method", $method);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
713 $input .= hpack(":path", $uri->{path});
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
714 $input .= hpack(":scheme", "http");
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
715 if ($version) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
716 $input .= hpack(":version", $version);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
717 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
718 if ($body) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
719 $input .= hpack("content-length", length $body);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
720 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
721 $input .= join '', map { hpack($_, $headers->{$_}) } keys %{$headers};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
722
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
723 $d = $ctx->{zlib}->{d};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
724 $status = $d->deflate($input => \my $start);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
725 $status == Compress::Raw::Zlib->Z_OK or fail "deflate failed";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
726 $status = $d->flush(\my $tail => Compress::Raw::Zlib->Z_SYNC_FLUSH);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
727 $status == Compress::Raw::Zlib->Z_OK or fail "flush failed";
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
728 $output = $start . $tail;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
729
426
7cb6af00afdd Tests: fixed SPDY tests with large header length.
Sergey Kandaurov <pluknet@nginx.com>
parents: 425
diff changeset
730 # 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
731
7cb6af00afdd Tests: fixed SPDY tests with large header length.
Sergey Kandaurov <pluknet@nginx.com>
parents: 425
diff changeset
732 $buf |= pack "x4N", length($output) + 10;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
733 $buf .= $output;
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 if (defined $body) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
736 $buf .= pack "NCxn", $ctx->{last_stream}, 0x01, length $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
737 $buf .= $body;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
738 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
739
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
740 raw_write($ctx->{socket}, $buf);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
741 return $ctx->{last_stream};
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
742 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
743
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
744 sub syn_reply {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
745 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
746 my ($i, $status);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
747 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
748 my $skip = 4;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
749
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
750 my $flags = unpack "\@$skip B8", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
751 $payload{fin} = substr($flags, 7, 1);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
752
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
753 my $length = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
754 $payload{length} = $length;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
755 $payload{type} = 'SYN_REPLY';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
756
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
757 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
758 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
759 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
760 $payload{sid} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
761
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
762 my $input = substr($buf, $skip, $length - 4);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
763 $i = $ctx->{zlib}->{i};
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 $status = $i->inflate($input => \my $out);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
766 fail "Failed: $status" unless $status == Compress::Raw::Zlib->Z_OK;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
767 $payload{headers} = hunpack($out);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
768 return \%payload;
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
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
771 sub rst_stream {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
772 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
773 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
774 my $skip = 5;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
775
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
776 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
777 $payload{type} = 'RST_STREAM';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
778 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
779 $payload{code} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
780 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
781 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
782
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
783 sub settings {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
784 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
785 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
786 my $skip = 4;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
787
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
788 $payload{flags} = unpack "\@$skip H", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
789 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
790 $payload{type} = 'SETTINGS';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
791
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
792 my $nent = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
793 for (1 .. $nent) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
794 my $flags = hex unpack "\@$skip H2", $buf; $skip += 1;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
795 my $id = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
796 $payload{$id}{flags} = $flags;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
797 $payload{$id}{value} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
798 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
799 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
800 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
801
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
802 sub ping {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
803 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
804 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
805 my $skip = 5;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
806
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
807 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
808 $payload{type} = 'PING';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
809 $payload{value} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
810 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
811 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
812
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
813 sub goaway {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
814 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
815 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
816 my $skip = 5;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
817
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
818 $payload{length} = hex unpack "\@$skip H6", $buf; $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
819 $payload{type} = 'GOAWAY';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
820 $payload{sid} = unpack "\@$skip N", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
821 $payload{code} = unpack "\@$skip N", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
822 return \%payload;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
823 }
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 sub window_update {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
826 my ($ctx, $buf) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
827 my %payload;
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
828 my $skip = 5;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
829
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
830 $payload{length} = hex(unpack "\@$skip H6", $buf); $skip += 3;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
831 $payload{type} = 'WINDOW_UPDATE';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
832
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
833 my $stream = unpack "\@$skip B32", $buf; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
834 substr($stream, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
835 $stream = unpack("N", pack("B32", $stream));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
836 $payload{sid} = $stream;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
837
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
838 my $value = unpack "\@$skip B32", $buf;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
839 substr($value, 0, 1) = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
840 $payload{wdelta} = unpack("N", pack("B32", $value));
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
841 return \%payload;
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 sub hpack {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
845 my ($name, $value) = @_;
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 pack("N", length($name)) . $name . pack("N", length($value)) . $value;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
848 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
849
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
850 sub hunpack {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
851 my ($data) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
852 my %headers;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
853 my $skip = 0;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
854
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
855 my $nent = unpack "\@$skip N", $data; $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
856 for (1 .. $nent) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
857 my $len = unpack("\@$skip N", $data); $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
858 my $name = unpack("\@$skip A$len", $data); $skip += $len;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
859
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
860 $len = unpack("\@$skip N", $data); $skip += 4;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
861 my $value = unpack("\@$skip A$len", $data); $skip += $len;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
862
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
863 $headers{$name} = $value;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
864 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
865 return \%headers;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
866 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
867
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
868 sub raw_read {
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
869 my ($s, $buf, $len) = @_;
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
870 my $got = '';
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
871
425
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
872 while (length($buf) < $len) {
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
873 $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
874 log_in($got);
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
875 $buf .= $got;
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
876 }
cc7da696a330 Tests: reduced execution time of SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 416
diff changeset
877 return $buf;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
878 }
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 sub raw_write {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
881 my ($s, $message) = @_;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
882
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
883 local $SIG{PIPE} = 'IGNORE';
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
884
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
885 while (IO::Select->new($s)->can_write(0.4)) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
886 log_out($message);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
887 my $n = $s->syswrite($message);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
888 last unless $n;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
889 $message = substr($message, $n);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
890 last unless length $message;
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 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
893
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
894 sub new_session {
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
895 my ($port, %extra) = @_;
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
896 my ($d, $i, $status, $s);
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
897
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
898 ($d, $status) = Compress::Raw::Zlib::Deflate->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
899 -WindowBits => 12,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
900 -Dictionary => dictionary(),
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
901 -Level => Compress::Raw::Zlib->Z_NO_COMPRESSION
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 fail "Zlib failure: $status" unless $d;
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 ($i, $status) = Compress::Raw::Zlib::Inflate->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
906 -WindowBits => Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB,
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
907 -Dictionary => dictionary()
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
908 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
909 fail "Zlib failure: $status" unless $i;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
910
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
911 $s = new_socket($port);
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
912
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
913 if ($extra{proxy}) {
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
914 raw_write($s, $extra{proxy});
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
915 }
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
916
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
917 return { zlib => { i => $i, d => $d },
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
918 socket => $s, last_stream => -1 };
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
919 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
920
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
921 sub new_socket {
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
922 my ($port) = @_;
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
923 my $s;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
924
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
925 $port = 8080 unless defined $port;
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
926
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
927 eval {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
928 local $SIG{ALRM} = sub { die "timeout\n" };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
929 local $SIG{PIPE} = sub { die "sigpipe\n" };
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
930 alarm(2);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
931 $s = IO::Socket::INET->new(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
932 Proto => 'tcp',
427
daea9cf92c14 Tests: added proxy protocol tests over SPDY.
Sergey Kandaurov <pluknet@nginx.com>
parents: 426
diff changeset
933 PeerAddr => "127.0.0.1:$port",
374
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
934 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
935 alarm(0);
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 alarm(0);
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
938
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
939 if ($@) {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
940 log_in("died: $@");
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
941 return undef;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
942 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
943
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
944 return $s;
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
945 }
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 sub dictionary {
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
948 join('', (map pack('N/a*', $_), qw(
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
949 options
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
950 head
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
951 post
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
952 put
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
953 delete
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
954 trace
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
955 accept
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
956 accept-charset
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
957 accept-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
958 accept-language
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
959 accept-ranges
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
960 age
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
961 allow
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
962 authorization
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
963 cache-control
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
964 connection
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
965 content-base
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
966 content-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
967 content-language
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
968 content-length
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
969 content-location
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
970 content-md5
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
971 content-range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
972 content-type
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
973 date
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
974 etag
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
975 expect
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
976 expires
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
977 from
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
978 host
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
979 if-match
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
980 if-modified-since
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
981 if-none-match
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
982 if-range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
983 if-unmodified-since
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
984 last-modified
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
985 location
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
986 max-forwards
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
987 pragma
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
988 proxy-authenticate
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
989 proxy-authorization
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
990 range
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
991 referer
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
992 retry-after
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
993 server
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
994 te
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
995 trailer
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
996 transfer-encoding
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
997 upgrade
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
998 user-agent
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
999 vary
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1000 via
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1001 warning
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1002 www-authenticate
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1003 method
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1004 get
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1005 status), "200 OK",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1006 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
1007 "100101201202205206300302303304305306307402405406407408409410",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1008 "411412413414415416417502504505",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1009 "203 Non-Authoritative Information",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1010 "204 No Content",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1011 "301 Moved Permanently",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1012 "400 Bad Request",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1013 "401 Unauthorized",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1014 "403 Forbidden",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1015 "404 Not Found",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1016 "500 Internal Server Error",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1017 "501 Not Implemented",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1018 "503 Service Unavailable",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1019 "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
1020 " 00:00:00",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1021 " Mon, Tue, Wed, Thu, Fri, Sat, Sun, GMT",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1022 "chunked,text/html,image/png,image/jpg,image/gif,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1023 "application/xml,application/xhtml+xml,text/plain,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1024 "text/javascript,public", "privatemax-age=gzip,deflate,",
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1025 "sdchcharset=utf-8charset=iso-8859-1,utf-,*,enq=0."
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1026 );
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1027 }
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1028
ac804fd1eb56 Tests: basic SPDY tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1029 ###############################################################################