Mercurial > hg > nginx-tests
annotate proxy_keepalive.t @ 1783:95ba1e704b7b
Tests: fixed version check for tests added in bd21a4a7c9f5.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 04 Aug 2022 09:41:44 -0700 |
parents | 882267679006 |
children | d329b05e20fa |
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 |
275
6cbcfb4ef7ee
Tests: correct has() checks for upstream keepalive tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
273
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy upstream_keepalive ssi rewrite/) |
593
6c0a5903d0ae
Tests: cleanup now duplicating tests for no alerts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
275
diff
changeset
|
28 ->plan(49)->write_file_expand('nginx.conf', <<'EOF'); |
250
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 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 server 127.0.0.1:8081; |
250
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 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
46 listen 127.0.0.1:8080; |
250
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_http_version 1.1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 proxy_set_header Connection ""; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 location / { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 proxy_pass http://backend; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 } |
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 location /unbuffered/ { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 proxy_pass http://backend; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 proxy_buffering off; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
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 location /inmemory/ { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 ssi on; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 rewrite ^ /ssi.html break; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 } |
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 EOF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 $t->write_file('ssi.html', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 '<!--#include virtual="/include$request_uri" set="x" -->' . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 'set: <!--#echo var="x" -->'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 $t->run_daemon(\&http_daemon); |
272
957fe2a76aa7
Tests: remove conditional startup from upstream keepalive tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
250
diff
changeset
|
75 $t->run(); |
250
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 $t->waitforsocket('127.0.0.1:' . port(8081)) |
273
36c75df75ca4
Tests: fix startup race in fastcgi_keepalive.t, proxy_keepalive.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
272
diff
changeset
|
78 or die "Can't start test backend"; |
36c75df75ca4
Tests: fix startup race in fastcgi_keepalive.t, proxy_keepalive.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
272
diff
changeset
|
79 |
250
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 ############################################################################### |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
595
6cdfd177319b
Tests: fixed typos and misspellings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
593
diff
changeset
|
82 # There are 3 mostly independent modes of upstream operation: |
250
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 # 1. Buffered, i.e. normal mode with "proxy_buffering on;" |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 # 2. Unbuffered, i.e. "proxy_buffering off;". |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 # 3. In memory, i.e. ssi <!--#include ... set --> |
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 # These all should be tested. |
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 my ($r, $n); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 # buffered |
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 like($r = http_get('/buffered/length1'), qr/SEE-THIS/, 'buffered'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 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
|
97 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 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
|
99 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 like(http_get('/buffered/chunked2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 'buffered chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 like($r = http_get('/buffered/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 'buffered complex 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/complex2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 'buffered complex 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/chunk01'), qr/200 OK/, 'buffered 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 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
|
112 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 like($r = http_head('/buffered/length/head1'), qr/(?!SEE-THIS)/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 'buffered head'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 like(http_head('/buffered/length/head2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 'buffered head 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_get('/buffered/empty1'), qr/200 OK/, 'buffered empty'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 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
|
122 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 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
|
124 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 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
|
126 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 like($r = http_get('/buffered/304len1'), qr/304 Not/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 'buffered 304 with length'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 like(http_get('/buffered/304len2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 'buffered 304 with length 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 # unbuffered |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 like($r = http_get('/unbuffered/length1'), qr/SEE-THIS/, 'unbuffered'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 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
|
138 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 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
|
140 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 like(http_get('/unbuffered/chunked2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 'unbuffered chunked 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 like($r = http_get('/unbuffered/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 'unbuffered complex 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/complex2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 'unbuffered complex 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/chunk01'), qr/200 OK/, 'unbuffered 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 like(http_get('/unbuffered/chunk02'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 'unbuffered 0 chunk 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 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
|
156 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 like(http_get('/unbuffered/empty2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 'unbuffered empty 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 like($r = http_head('/unbuffered/length/head1'), qr/(?!SEE-THIS)/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 'unbuffered head'); |
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_head('/unbuffered/length/head2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 'unbuffered head 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_get('/unbuffered/304nolen1'), qr/304 Not/, 'unbuffered 304'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 $r =~ m/X-Connection: (\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 like(http_get('/unbuffered/304nolen2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 'unbuffered 304 2'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 like($r = http_get('/unbuffered/304len1'), qr/304 Not/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 'unbuffered 304 with length'); |
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/304len2'), qr/X-Connection: $n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 'unbuffered 304 with length 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 # in memory |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 like($r = http_get('/inmemory/length1'), qr/SEE-THIS/, 'inmemory'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 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
|
182 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 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
|
184 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 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
|
186 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 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
|
188 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 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
|
190 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 like($r = http_get('/inmemory/complex1'), qr/(0123456789){100}/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 'inmemory complex chunked'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 $r =~ m/SEE-THIS(\d+)/; $n = $1; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 like(http_get('/inmemory/complex2'), qr/SEE-THIS$n/, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 'inmemory complex 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(http_get('/inmemory/chunk01'), qr/set: $/, 'inmemory 0 chunk'); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 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
|
199 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 # closed connection tests |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 # check for errors, shouldn't be any |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 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
|
212 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 ############################################################################### |
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 sub http_daemon { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 my $server = IO::Socket::INET->new( |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 Proto => 'tcp', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
218 LocalHost => '127.0.0.1:' . port(8081), |
250
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 Listen => 5, |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 Reuse => 1 |
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 or die "Can't create listening socket: $!\n"; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 my $ccount = 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 my $rcount = 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 # dumb server which is able to keep connections alive |
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 while (my $client = $server->accept()) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 Test::Nginx::log_core('||', |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 "connection from " . $client->peerhost()); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 $client->autoflush(1); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 $ccount++; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 while (1) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 my $headers = ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 my $uri = ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 while (<$client>) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 Test::Nginx::log_core('||', $_); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 $headers .= $_; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 last if (/^\x0d?\x0a?$/); |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 last if $headers eq ''; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 $rcount++; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 if ($uri =~ m/length/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 "Content-Length: 26" . CRLF . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 print $client "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 sprintf("%03d", $ccount) |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 } elsif ($uri =~ m/empty/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 "Content-Length: 0" . CRLF . CRLF; |
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/304nolen/) { |
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 304 Not Modified" . 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 . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 } elsif ($uri =~ m/304len/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 "HTTP/1.1 304 Not Modified" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 "Content-Length: 100" . 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/chunked/) { |
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 200 OK" . 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 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 "1a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 sprintf("%03d", $ccount) . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 "0" . CRLF . CRLF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 } elsif ($uri =~ m/complex/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
301 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
302 if ($headers !~ /^HEAD/i) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 for my $n (1..100) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 "a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 "0123456789" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 select undef, undef, undef, 0.01 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 if $n % 50 == 0; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 "1a" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 "TEST-OK-IF-YOU-SEE-THIS" . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 sprintf("%03d", $ccount) . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 "0" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 select undef, undef, undef, 0.05; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 print $client CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 } elsif ($uri =~ m/chunk0/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 "Transfer-Encoding: chunked" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 "0" . CRLF . CRLF |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 unless $headers =~ /^HEAD/i; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
331 } elsif ($uri =~ m/closed/) { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
332 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
333 "HTTP/1.1 200 OK" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
334 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 "Connection: close" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 "Content-Length: 12" . CRLF . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 "0123456789" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
339 last; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
340 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
341 } else { |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
342 print $client |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
343 "HTTP/1.1 404 Not Found" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
344 "X-Request: $rcount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
345 "X-Connection: $ccount" . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
346 "Connection: close" . CRLF . CRLF . |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
347 "Oops, '$uri' not found" . CRLF; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
348 last; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
349 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
350 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
351 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
352 close $client; |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
353 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
354 } |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
355 |
0c9f15938545
Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
356 ############################################################################### |