annotate proxy.t @ 1423:29d0961bc3f7

Tests: aligned generic read timeouts in stream and mail tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 25 Dec 2018 13:56:49 +0300
parents 16a8962ff246
children fc8341cf92a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 # (C) Maxim Dounin
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 # Tests for http proxy module.
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7 ###############################################################################
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 use warnings;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10 use strict;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11
121
8ac1faaddd2c Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents: 107
diff changeset
12 use Test::More;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
924
54680c434afa Tests: fixed proxy.t on platforms without IPv6 support.
Sergey Kandaurov <pluknet@nginx.com>
parents: 922
diff changeset
14 use Socket;
54680c434afa Tests: fixed proxy.t on platforms without IPv6 support.
Sergey Kandaurov <pluknet@nginx.com>
parents: 922
diff changeset
15
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18 use lib 'lib';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 use Test::Nginx;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 ###############################################################################
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23 select STDERR; $| = 1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 select STDOUT; $| = 1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(31);
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28 $t->write_file_expand('nginx.conf', <<'EOF');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
29
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
30 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
31
249
6a0d934950bc Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents: 166
diff changeset
32 daemon off;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 events {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
38 %%TEST_GLOBALS_HTTP%%
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
40 log_format time '$upstream_connect_time:$upstream_header_time:'
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
41 '$upstream_response_time';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
42
802
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
43 upstream u {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
44 server 127.0.0.1:8081;
802
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
45 }
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
46
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
47 upstream u2 {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
48 server 127.0.0.1:8081;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
49 server 127.0.0.1:8081;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
50 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
51
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
53 listen 127.0.0.1:8080;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 server_name localhost;
731
cf9183219c59 Tests: removed debugging leftover.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
55
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
56 add_header X-Connect $upstream_connect_time;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
57 add_header X-Header $upstream_header_time;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
58 add_header X-Response $upstream_response_time;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
59
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 location / {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
61 proxy_pass http://127.0.0.1:8081;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 proxy_read_timeout 1s;
795
122cd3a82367 Tests: fixed 'proxy connect timeout' test timeouts on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 732
diff changeset
63 proxy_connect_timeout 2s;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 }
434
a8596c7b33cc Tests: style.
Maxim Dounin <mdounin@mdounin.ru>
parents: 432
diff changeset
65
432
c1269426585d Tests: test for implicit upstream with IP literal and variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 295
diff changeset
66 location /var {
434
a8596c7b33cc Tests: style.
Maxim Dounin <mdounin@mdounin.ru>
parents: 432
diff changeset
67 proxy_pass http://$arg_b;
a8596c7b33cc Tests: style.
Maxim Dounin <mdounin@mdounin.ru>
parents: 432
diff changeset
68 proxy_read_timeout 1s;
1006
e4d5e7afb6e0 Tests: speed up proxy.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
69 proxy_connect_timeout 2s;
432
c1269426585d Tests: test for implicit upstream with IP literal and variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 295
diff changeset
70 }
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
71
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
72 location /timeout {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
73 proxy_pass http://127.0.0.1:8081;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
74 proxy_connect_timeout 2s;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
75 }
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
76
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
77 location /time/ {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
78 proxy_pass http://127.0.0.1:8081/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
79 access_log %%TESTDIR%%/time.log time;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
80 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
81
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
82 location /pnu {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
83 proxy_pass http://u2/bad;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
84 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
85
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
86 location /vars {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
87 proxy_pass http://127.0.0.1:8080/stub;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
88
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
89 add_header X-Proxy-Host $proxy_host;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
90 add_header X-Proxy-Port $proxy_port;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
91 add_header X-Proxy-Forwarded $proxy_add_x_forwarded_for;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
92 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
93
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
94 location /stub { }
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
95 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
96 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
98 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
100 $t->write_file('stub', '');
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101 $t->run_daemon(\&http_daemon);
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
102 $t->run()->waitforsocket('127.0.0.1:' . port(8081));
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
103
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
104 ###############################################################################
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
105
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
106 like(http_get('/'), qr/SEE-THIS/, 'proxy request');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
108
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
109 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
111 like(http_get('/var?b=127.0.0.1:' . port(8081) . '/'), qr/SEE-THIS/,
952
e9064d691790 Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 924
diff changeset
112 'proxy with variables');
802
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
113 like(http_get('/var?b=u/'), qr/SEE-THIS/, 'proxy with variables to upstream');
922
93d900bac201 Tests: added regression test for proxy with no IPv6 port specified.
Sergey Kandaurov <pluknet@nginx.com>
parents: 802
diff changeset
114 ok(http_get("/var?b=[::]"), 'proxy with variables - no ipv6 port');
93d900bac201 Tests: added regression test for proxy with no IPv6 port specified.
Sergey Kandaurov <pluknet@nginx.com>
parents: 802
diff changeset
115
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
116 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
732
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 731
diff changeset
117
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
118 my $re = qr/(\d\.\d{3})/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
119 my $p0 = port(8080);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
120 my ($ct, $ht, $rt, $ct2, $ht2, $rt2, $ct3, $ht3, $rt3);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
121
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
122 like(http_get('/vars'), qr/X-Proxy-Host:\s127\.0\.0\.1:$p0/, 'proxy_host');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
123 like(http_get('/vars'), qr/X-Proxy-Port:\s$p0/, 'proxy_port');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
124 like(http_xff('/vars', '192.0.2.1'), qr/X-Proxy-Forwarded:.*192\.0\.2\.1/,
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
125 'proxy_add_x_forwarded_for');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
126
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
127 ($ct, $ht) = get('/time/header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
128 cmp_ok($ct, '<', 1, 'connect time - slow response header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
129 cmp_ok($ht, '>=', 1, 'header time - slow response header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
130
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
131 ($ct, $ht) = get('/time/body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
132 cmp_ok($ct, '<', 1, 'connect time - slow response body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
133 cmp_ok($ht, '<', 1, 'header time - slow response body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
134
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
135 my $s = http_get('/time/header', start => 1);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
136 select undef, undef, undef, 0.4;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
137 close ($s);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
138
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
139 # expect no header time in 1st (bad) upstream, no (yet) response time in 2nd
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
140
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
141 $re = qr/(\d\.\d{3}|-)/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
142 ($ct, $ct2, $ht, $ht2, $rt, $rt2) = get('/pnu', many => 1);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
143 cmp_ok($ct, '<', 1, 'connect time - next');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
144 cmp_ok($ct2, '<', 1, 'connect time - next 2');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
145
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
146 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
147 local $TODO = 'not yet' unless $t->has_version('1.15.7');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
148
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
149 is($ht, '-', 'header time - next');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
150
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
151 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
152
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
153 cmp_ok($ht2, '<', 1, 'header time - next 2');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
154 cmp_ok($rt, '>=', 1, 'response time - next');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
155
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
156 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
157 local $TODO = 'not yet' unless $t->has_version('1.15.7');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
158
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
159 is($rt2, '-', 'response time - next 2');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
160
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
161 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
162
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
163 $t->stop();
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
164
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
165 ($ct, $ht, $rt, $ct2, $ht2, $rt2, $ct3, $ht3, $rt3)
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
166 = $t->read_file('time.log') =~ /^$re:$re:$re\n$re:$re:$re\n$re:$re:$re$/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
167
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
168 cmp_ok($ct, '<', 1, 'connect time log - slow response header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
169 cmp_ok($ct2, '<', 1, 'connect time log - slow response body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
170
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
171 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
172 local $TODO = 'not yet' unless $t->has_version('1.15.7');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
173
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
174 isnt($ct3, '-', 'connect time log - client close set');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
175
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
176 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
177
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
178 $ct3 = 0 if $ct3 eq '-';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
179 cmp_ok($ct3, '<', 1, 'connect time log - client close');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
180
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
181 cmp_ok($ht, '>=', 1, 'header time log - slow response header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
182 cmp_ok($ht2, '<', 1, 'header time log - slow response body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
183 is($ht3, '-', 'header time log - client close');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
184
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
185 cmp_ok($rt, '>=', 1, 'response time log - slow response header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
186 cmp_ok($rt2, '>=', 1, 'response time log - slow response body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
187
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
188 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
189 local $TODO = 'not yet' unless $t->has_version('1.15.7');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
190
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
191 isnt($rt3, '-', 'response time log - client close set');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
192 $rt3 = 0 if $rt3 eq '-';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
193 cmp_ok($rt3, '>', $ct3, 'response time log - client close');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
194
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
195 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
196
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
197 ###############################################################################
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
198
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
199 sub get {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
200 my ($uri, %extra) = @_;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
201 my $re = $extra{many} ? qr/$re, $re?/ : $re;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
202 my $r = http_get($uri);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
203 $r =~ /X-Connect: $re/, $r =~ /X-Header: $re/, $r =~ /X-Response: $re/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
204 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
205
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
206 sub http_xff {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
207 my ($uri, $xff) = @_;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
208 return http(<<EOF);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
209 GET $uri HTTP/1.0
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
210 Host: localhost
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
211 X-Forwarded-For: $xff
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
212
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
213 EOF
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
214 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
215
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
216 sub http_daemon {
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
217 my $once = 1;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
218 my $server = IO::Socket::INET->new(
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
219 Proto => 'tcp',
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
220 LocalHost => '127.0.0.1:' . port(8081),
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
221 Listen => 5,
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
222 Reuse => 1
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
223 )
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
224 or die "Can't create listening socket: $!\n";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
225
295
6fe0459b6668 Tests: eliminate startup races in proxy and fastcgi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 249
diff changeset
226 local $SIG{PIPE} = 'IGNORE';
6fe0459b6668 Tests: eliminate startup races in proxy and fastcgi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 249
diff changeset
227
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
228 while (my $client = $server->accept()) {
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
229 $client->autoflush(1);
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
230
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
231 my $headers = '';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
232 my $uri = '';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
233
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
234 while (<$client>) {
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
235 $headers .= $_;
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
236 last if (/^\x0d?\x0a?$/);
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
237 }
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
238
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
239 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
240
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
241 if ($uri eq '/') {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
242 print $client <<'EOF';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
243 HTTP/1.1 200 OK
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
244 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
245
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
246 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
247 print $client "TEST-OK-IF-YOU-SEE-THIS"
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
248 unless $headers =~ /^HEAD/i;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
249
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
250 } elsif ($uri eq '/multi') {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
251
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
252 print $client <<"EOF";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
253 HTTP/1.1 200 OK
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
254 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
255
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
256 TEST-OK-IF-YOU-SEE-THIS
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
257 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
258
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
259 select undef, undef, undef, 0.1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
260 print $client 'AND-THIS';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
261
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
262 } elsif ($uri eq '/timeout') {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
263 sleep 3;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
264
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
265 print $client <<"EOF";
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
266 HTTP/1.1 200 OK
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
267 Connection: close
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
268
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
269 EOF
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
270
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
271 } elsif ($uri eq '/bad') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
272
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
273 if ($once) {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
274 $once = 0;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
275 select undef, undef, undef, 1.1;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
276 next;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
277 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
278
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
279 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
280 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
281 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
282
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
283 SEE-THIS-AND-THIS
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
284 EOF
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
285
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
286 } elsif ($uri eq '/header') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
287 select undef, undef, undef, 1.1;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
288
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
289 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
290 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
291 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
292
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
293 SEE-THIS-AND-THIS;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
294 EOF
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
295
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
296 } elsif ($uri eq '/body') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
297
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
298 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
299 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
300 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
301
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
302 SEE-THIS-
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
303 EOF
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
304
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
305 select undef, undef, undef, 1.1;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
306 print $client 'AND-THIS';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
307
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
308 } else {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
309
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
310 print $client <<"EOF";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
311 HTTP/1.1 404 Not Found
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
312 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
313
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
314 Oops, '$uri' not found
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
315 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
316 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
317
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
318 close $client;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
319 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
320 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
321
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
322 ###############################################################################