Mercurial > hg > nginx-tests
annotate proxy_keepalive.t @ 251:df984d23f9d1
Tests: improve fastcgi keepalive tests.
On some platforms fastcgi_keepalive.t tests failed due to problems in
handling of data split into multiple packets. Harden tests to fail
on all platforms by adding more sleeps, and mark them as TODO till
underlying problems are fixed.
Additionally, add some padding testing.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 25 Jan 2013 20:53:53 +0400 |
parents | 0c9f15938545 |
children | 957fe2a76aa7 |
rev | line source |
---|---|
250
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for proxy with keepalive. |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use IO::Socket::INET; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 use Socket qw/ CRLF /; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use lib 'lib'; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 use Test::Nginx; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 ############################################################################### |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy ssi rewrite/) |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 daemon off; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 upstream backend { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 server 127.0.0.1:8081; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 keepalive 1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 server { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 listen 127.0.0.1:8080; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 server_name localhost; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 proxy_read_timeout 2s; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 proxy_http_version 1.1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 proxy_set_header Connection ""; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 location / { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 proxy_pass http://backend; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 location /unbuffered/ { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 proxy_pass http://backend; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 proxy_buffering off; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 location /inmemory/ { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 ssi on; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 rewrite ^ /ssi.html break; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 EOF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 $t->write_file('ssi.html', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 '<!--#include virtual="/include$request_uri" set="x" -->' . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 'set: <!--#echo var="x" -->'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 $t->run_daemon(\&http_daemon); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 eval { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 open OLDERR, ">&", \*STDERR; close STDERR; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 $t->run(); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 open STDERR, ">&", \*OLDERR; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 }; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 plan(skip_all => 'no keepalive patches') if $@; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 $t->plan(50); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 ############################################################################### |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 # There are 3 mostly independend modes of upstream operation: |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 # |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 # 1. Buffered, i.e. normal mode with "proxy_buffering on;" |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 # 2. Unbuffered, i.e. "proxy_buffering off;". |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 # 3. In memory, i.e. ssi <!--#include ... set --> |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 # |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 # These all should be tested. |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 my ($r, $n); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 # buffered |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 like($r = http_get('/buffered/length1'), qr/SEE-THIS/, 'buffered'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 like(http_get('/buffered/length2'), qr/X-Connection: $n.*SEE/ms, 'buffered 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 like($r = http_get('/buffered/chunked1'), qr/SEE-THIS/, 'buffered chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 like(http_get('/buffered/chunked2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 'buffered chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 like($r = http_get('/buffered/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 'buffered complex chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 like(http_get('/buffered/complex2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 'buffered complex chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 like($r = http_get('/buffered/chunk01'), qr/200 OK/, 'buffered 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 like(http_get('/buffered/chunk02'), qr/X-Connection: $n/, 'buffered 0 chunk 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 like($r = http_head('/buffered/length/head1'), qr/(?!SEE-THIS)/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 'buffered head'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 like(http_head('/buffered/length/head2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 'buffered head 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 like($r = http_get('/buffered/empty1'), qr/200 OK/, 'buffered empty'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 like(http_get('/buffered/empty2'), qr/X-Connection: $n/, 'buffered empty 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 like($r = http_get('/buffered/304nolen1'), qr/304 Not/, 'buffered 304'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 like(http_get('/buffered/304nolen2'), qr/X-Connection: $n/, 'buffered 304 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 like($r = http_get('/buffered/304len1'), qr/304 Not/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 'buffered 304 with length'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 like(http_get('/buffered/304len2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 'buffered 304 with length 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 # unbuffered |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 like($r = http_get('/unbuffered/length1'), qr/SEE-THIS/, 'unbuffered'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 like(http_get('/unbuffered/length2'), qr/X-Connection: $n/, 'unbuffered 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 like($r = http_get('/unbuffered/chunked1'), qr/SEE-THIS/, 'unbuffered chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 like(http_get('/unbuffered/chunked2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 'unbuffered chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 like($r = http_get('/unbuffered/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 'unbuffered complex chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 like(http_get('/unbuffered/complex2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 'unbuffered complex chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 like($r = http_get('/unbuffered/chunk01'), qr/200 OK/, 'unbuffered 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 like(http_get('/unbuffered/chunk02'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 'unbuffered 0 chunk 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 like($r = http_get('/unbuffered/empty1'), qr/200 OK/, 'unbuffered empty'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 like(http_get('/unbuffered/empty2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 'unbuffered empty 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 like($r = http_head('/unbuffered/length/head1'), qr/(?!SEE-THIS)/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 'unbuffered head'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 like(http_head('/unbuffered/length/head2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 'unbuffered head 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 like($r = http_get('/unbuffered/304nolen1'), qr/304 Not/, 'unbuffered 304'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 like(http_get('/unbuffered/304nolen2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 'unbuffered 304 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 like($r = http_get('/unbuffered/304len1'), qr/304 Not/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 'unbuffered 304 with length'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 like(http_get('/unbuffered/304len2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 'unbuffered 304 with length 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 # in memory |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 like($r = http_get('/inmemory/length1'), qr/SEE-THIS/, 'inmemory'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 like(http_get('/inmemory/length2'), qr/SEE-THIS$n/, 'inmemory 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 like($r = http_get('/inmemory/empty1'), qr/200 OK/, 'inmemory empty'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 like(http_get('/inmemory/empty2'), qr/200 OK/, 'inmemory empty 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 like($r = http_get('/inmemory/chunked1'), qr/SEE-THIS/, 'inmemory chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 like(http_get('/inmemory/chunked2'), qr/SEE-THIS$n/, 'inmemory chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 like($r = http_get('/inmemory/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 'inmemory complex chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 like(http_get('/inmemory/complex2'), qr/SEE-THIS$n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 'inmemory complex chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
203 like(http_get('/inmemory/chunk01'), qr/set: $/, 'inmemory 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 like(http_get('/inmemory/chunk02'), qr/set: $/, 'inmemory 0 chunk 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 # closed connection tests |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 like(http_get('/buffered/closed1'), qr/200 OK/, 'buffered closed 1'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 like(http_get('/buffered/closed2'), qr/200 OK/, 'buffered closed 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 like(http_get('/unbuffered/closed1'), qr/200 OK/, 'unbuffered closed 1'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 like(http_get('/unbuffered/closed2'), qr/200 OK/, 'unbuffered closed 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 like(http_get('/inmemory/closed1'), qr/200 OK/, 'inmemory closed 1'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 like(http_get('/inmemory/closed2'), qr/200 OK/, 'inmemory closed 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 # check for errors, shouldn't be any |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 like(`grep -F '[error]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no errors'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 ############################################################################### |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 sub http_daemon { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 my $server = IO::Socket::INET->new( |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 Proto => 'tcp', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 LocalHost => '127.0.0.1:8081', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 Listen => 5, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 Reuse => 1 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 ) |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 or die "Can't create listening socket: $!\n"; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 my $ccount = 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 my $rcount = 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 # dumb server which is able to keep connections alive |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 while (my $client = $server->accept()) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 Test::Nginx::log_core('||', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 "connection from " . $client->peerhost()); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 $client->autoflush(1); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 $ccount++; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 while (1) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 my $headers = ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 my $uri = ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 while (<$client>) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 Test::Nginx::log_core('||', $_); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 $headers .= $_; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 last if (/^\x0d?\x0a?$/); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 last if $headers eq ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 $rcount++; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 if ($uri =~ m/length/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 "Content-Length: 26" . CRLF . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 print $client "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 sprintf("%03d", $ccount) |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 } elsif ($uri =~ m/empty/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 "Content-Length: 0" . CRLF . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 } elsif ($uri =~ m/304nolen/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 "HTTP/1.1 304 Not Modified" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 "X-Connection: $ccount" . CRLF . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 } elsif ($uri =~ m/304len/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 "HTTP/1.1 304 Not Modified" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
283 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 "Content-Length: 100" . CRLF . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 } elsif ($uri =~ m/chunked/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 "1a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 sprintf("%03d", $ccount) . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 "0" . CRLF . CRLF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
301 } elsif ($uri =~ m/complex/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
302 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 if ($headers !~ /^HEAD/i) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 for my $n (1..100) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 "a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 "0123456789" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 select undef, undef, undef, 0.01 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 if $n % 50 == 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 "1a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 sprintf("%03d", $ccount) . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 "0" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 select undef, undef, undef, 0.05; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 print $client CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 } elsif ($uri =~ m/chunk0/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
331 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
332 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
333 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
334 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 "0" . CRLF . CRLF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 } elsif ($uri =~ m/closed/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
339 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
340 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
341 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
342 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
343 "Connection: close" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
344 "Content-Length: 12" . CRLF . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
345 "0123456789" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
346 last; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
347 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
348 } else { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
349 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
350 "HTTP/1.1 404 Not Found" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
351 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 "Connection: close" . CRLF . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 "Oops, '$uri' not found" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 last; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
357 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
358 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
359 close $client; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
360 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
361 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
362 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
363 ############################################################################### |