annotate proxy_unfinished.t @ 299:44c42894fdfd

Tests: move unfinished tests to a separate file. Add more tests to catch unfinished chunked responses, as well as proxy-only aspect of the problem (we shouldn't send final chunk if we know the response isn't complete).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 11 Jun 2013 17:14:37 +0400
parents
children 81c98592661f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
299
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 # (C) Maxim Dounin
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 # Tests for http proxy and prematurely closed connections. Incomplete
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6 # responses shouldn't loose information about their incompleteness.
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8 # In particular, incomplete responses:
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 #
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10 # - shouldn't be cached
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11 #
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 # - if a response is sent using chunked transfer encoding,
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13 # final chunk shouldn't be sent
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15 ###############################################################################
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use warnings;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18 use strict;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20 use Test::More;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 use Socket qw/ CRLF /;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 BEGIN { use FindBin; chdir($FindBin::Bin); }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 use lib 'lib';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27 use Test::Nginx;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
29 ###############################################################################
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
30
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31 select STDERR; $| = 1;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32 select STDOUT; $| = 1;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 plan(skip_all => 'win32') if $^O eq 'MSWin32';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 my $t = Test::Nginx->new()->has(qw/http proxy cache sub/)->plan(4)
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 ->write_file_expand('nginx.conf', <<'EOF');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 %%TEST_GLOBALS%%
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41 daemon off;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 events {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
46 http {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 %%TEST_GLOBALS_HTTP%%
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49 proxy_cache_path %%TESTDIR%%/cache levels=1:2
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 keys_zone=one:1m;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 server {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53 listen 127.0.0.1:8080;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 server_name localhost;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56 location / {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57 sub_filter foo bar;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 sub_filter_types *;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 proxy_pass http://127.0.0.1:8081;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 location /cache/ {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 proxy_pass http://127.0.0.1:8081/;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 proxy_cache one;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
68
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
69 EOF
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
70
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
71 $t->run_daemon(\&http_daemon);
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
72 $t->run()->waitforsocket('127.0.0.1:8081');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
73
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74 ###############################################################################
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 my ($r, $n);
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78 $r = http_get('/cache/length');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 $r =~ m/unfinished (\d+)/; $n = $1 + 1;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 like(http_get('/cache/length'), qr/unfinished $n/, 'unfinished not cached');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82 TODO: {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 local $TODO = 'not yet';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85 # chunked encoding has enough information to don't cache a response,
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86 # much like with Content-Length available
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
88 $r = http_get('/cache/chunked');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89 $r =~ m/unfinished (\d+)/; $n = $1 + 1;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90 like(http_get('/cache/chunked'), qr/unfinished $n/, 'unfinished chunked');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
92 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
94 TODO: {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
95 local $TODO = 'not yet';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
96
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97 # make sure there is no final chunk in normal responses
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
98
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99 like(http_get_11('/length'), qr/unfinished(?!.*\x0d\x0a?0\x0d\x0a?)/s,
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
100 'length no final chunk');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101 like(http_get_11('/chunked'), qr/unfinished(?!.*\x0d\x0a?0\x0d\x0a?)/s,
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
102 'chunked no final chunk');
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
103
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
104 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
105
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
106 ###############################################################################
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
108 sub http_get_11 {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
109 my ($uri) = @_;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
111 return http(
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
112 "GET $uri HTTP/1.1" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
113 "Connection: close" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114 "Host: localhost" . CRLF . CRLF
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
115 );
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
116 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
117
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
118 ###############################################################################
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
119
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
120 sub http_daemon {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
121 my $server = IO::Socket::INET->new(
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
122 Proto => 'tcp',
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
123 LocalAddr => '127.0.0.1:8081',
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
124 Listen => 5,
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
125 Reuse => 1
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
126 )
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
127 or die "Can't create listening socket: $!\n";
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
128
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
129 local $SIG{PIPE} = 'IGNORE';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
130
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131 my $num = 0;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
133 while (my $client = $server->accept()) {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
134 $client->autoflush(1);
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
135
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136 my $headers = '';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 my $uri = '';
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
138
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
139 while (<$client>) {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140 $headers .= $_;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141 last if (/^\x0d?\x0a?$/);
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
142 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
143
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
144 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
145 $num++;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
146
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
147 if ($uri eq '/length') {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
148 print $client
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
149 "HTTP/1.1 200 OK" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
150 "Content-Length: 100" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
151 "Cache-Control: max-age=300" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
152 "Connection: close" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
153 CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
154 "unfinished $num" . CRLF;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
155
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
156 } elsif ($uri eq '/chunked') {
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
157 print $client
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
158 "HTTP/1.1 200 OK" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
159 "Transfer-Encoding: chunked" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
160 "Cache-Control: max-age=300" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
161 "Connection: close" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
162 CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
163 "ff" . CRLF .
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
164 "unfinished $num" . CRLF;
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
165 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
166 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
167 }
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
168
44c42894fdfd Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
169 ###############################################################################