annotate proxy.t @ 1477:8b122b35703b

Tests: fixed session reuse tests in ssl_certificate.t with TLSv1.3. Previously, session data was retrieved too early, before server passed application data, which usually means NewSessionTicket is not yet sent. The fix is to ask server for application data, then retrieve a session.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 20 May 2019 16:00:40 +0300
parents 7959e58429d0
children 144c6ce732e4
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
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 use lib 'lib';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use Test::Nginx;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 ###############################################################################
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 select STDERR; $| = 1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 select STDOUT; $| = 1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
1434
fc8341cf92a3 Tests: removed ngx_parse_inet6_url() "::" test from proxy.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1419
diff changeset
24 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(30);
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 $t->write_file_expand('nginx.conf', <<'EOF');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
28 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
29
249
6a0d934950bc Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents: 166
diff changeset
30 daemon off;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32 events {
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
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 83
diff changeset
36 %%TEST_GLOBALS_HTTP%%
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
38 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
39 '$upstream_response_time';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
40
802
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
41 upstream u {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
42 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
43 }
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
44
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
45 upstream u2 {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
46 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
47 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
48 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
49
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
51 listen 127.0.0.1:8080;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 server_name localhost;
731
cf9183219c59 Tests: removed debugging leftover.
Sergey Kandaurov <pluknet@nginx.com>
parents: 717
diff changeset
53
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
54 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
55 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
56 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
57
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 location / {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
59 proxy_pass http://127.0.0.1:8081;
1461
7959e58429d0 Tests: adjusted proxy.t proxy_read_timeout for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1460
diff changeset
60 proxy_read_timeout 2s;
795
122cd3a82367 Tests: fixed 'proxy connect timeout' test timeouts on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 732
diff changeset
61 proxy_connect_timeout 2s;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 }
434
a8596c7b33cc Tests: style.
Maxim Dounin <mdounin@mdounin.ru>
parents: 432
diff changeset
63
432
c1269426585d Tests: test for implicit upstream with IP literal and variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 295
diff changeset
64 location /var {
434
a8596c7b33cc Tests: style.
Maxim Dounin <mdounin@mdounin.ru>
parents: 432
diff changeset
65 proxy_pass http://$arg_b;
1461
7959e58429d0 Tests: adjusted proxy.t proxy_read_timeout for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1460
diff changeset
66 proxy_read_timeout 2s;
1006
e4d5e7afb6e0 Tests: speed up proxy.t on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
67 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
68 }
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
69
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
70 location /timeout {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
71 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
72 proxy_connect_timeout 2s;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
73 }
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
74
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
75 location /time/ {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
76 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
77 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
78 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
79
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
80 location /pnu {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
81 proxy_pass http://u2/bad;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
82 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
83
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
84 location /vars {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
85 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
86
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
87 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
88 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
89 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
90 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
91
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
92 location /stub { }
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
94 }
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 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
98 $t->write_file('stub', '');
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99 $t->run_daemon(\&http_daemon);
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
100 $t->run()->waitforsocket('127.0.0.1:' . port(8081));
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
102 ###############################################################################
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 like(http_get('/'), qr/SEE-THIS/, 'proxy request');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
105 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
106
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request');
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
108
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
109 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
110 'proxy with variables');
802
eca9b1d19021 Tests: tests for host expansion to an explicit upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents: 795
diff changeset
111 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
112
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
113 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
114
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
115 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
116 my $p0 = port(8080);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
117 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
118
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
119 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
120 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
121 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
122 'proxy_add_x_forwarded_for');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
123
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
124 ($ct, $ht) = get('/time/header');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
125 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
126 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
127
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
128 ($ct, $ht) = get('/time/body');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
129 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
130 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
131
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
132 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
133 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
134 close ($s);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
135
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
136 # 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
137
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
138 $re = qr/(\d\.\d{3}|-)/;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
139 ($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
140 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
141 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
142
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
143 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
144 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
145
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
146 is($ht, '-', 'header time - next');
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
147
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
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
150 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
151 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
152
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
153 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
154 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
155
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
156 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
157
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
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
160 $t->stop();
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 ($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
163 = $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
164
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
165 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
166 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
167
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
168 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
169 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
170
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
171 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
172
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
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
175 $ct3 = 0 if $ct3 eq '-';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
176 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
177
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
178 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
179 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
180 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
181
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
182 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
183 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
184
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
185 TODO: {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
186 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
187
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
188 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
189 $rt3 = 0 if $rt3 eq '-';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
190 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
191
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
192 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
193
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
194 ###############################################################################
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
195
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
196 sub get {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
197 my ($uri, %extra) = @_;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
198 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
199 my $r = http_get($uri);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
200 $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
201 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
202
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
203 sub http_xff {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
204 my ($uri, $xff) = @_;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
205 return http(<<EOF);
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
206 GET $uri HTTP/1.0
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
207 Host: localhost
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
208 X-Forwarded-For: $xff
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
209
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
210 EOF
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
211 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
212
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
213 sub http_daemon {
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
214 my $once = 1;
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
215 my $server = IO::Socket::INET->new(
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
216 Proto => 'tcp',
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
217 LocalHost => '127.0.0.1:' . port(8081),
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
218 Listen => 5,
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
219 Reuse => 1
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
220 )
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
221 or die "Can't create listening socket: $!\n";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
222
295
6fe0459b6668 Tests: eliminate startup races in proxy and fastcgi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 249
diff changeset
223 local $SIG{PIPE} = 'IGNORE';
6fe0459b6668 Tests: eliminate startup races in proxy and fastcgi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 249
diff changeset
224
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
225 while (my $client = $server->accept()) {
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
226 $client->autoflush(1);
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
227
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
228 my $headers = '';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
229 my $uri = '';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
230
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
231 while (<$client>) {
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
232 $headers .= $_;
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
233 last if (/^\x0d?\x0a?$/);
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
234 }
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
235
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
236 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
237
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
238 if ($uri eq '/') {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
239 print $client <<'EOF';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
240 HTTP/1.1 200 OK
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
241 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
242
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
243 EOF
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
244 print $client "TEST-OK-IF-YOU-SEE-THIS"
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
245 unless $headers =~ /^HEAD/i;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
246
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
247 } elsif ($uri eq '/multi') {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
248
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
249 print $client <<"EOF";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
250 HTTP/1.1 200 OK
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
251 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
252
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
253 TEST-OK-IF-YOU-SEE-THIS
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
254 EOF
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 select undef, undef, undef, 0.1;
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
257 print $client 'AND-THIS';
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
258
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
259 } elsif ($uri eq '/timeout') {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
260 sleep 3;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
261
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
262 print $client <<"EOF";
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
263 HTTP/1.1 200 OK
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
264 Connection: close
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
265
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
266 EOF
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1006
diff changeset
267
1419
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
268 } elsif ($uri eq '/bad') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
269
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
270 if ($once) {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
271 $once = 0;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
272 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
273 next;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
274 }
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
275
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
276 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
277 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
278 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
279
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
280 SEE-THIS-AND-THIS
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
281 EOF
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 } elsif ($uri eq '/header') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
284 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
285
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
286 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
287 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
288 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
289
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
290 SEE-THIS-AND-THIS;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
291 EOF
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 } elsif ($uri eq '/body') {
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
294
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
295 print $client <<EOF;
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
296 HTTP/1.1 200 OK
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
297 Connection: close
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
298
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
299 SEE-THIS-
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
300 EOF
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 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
303 print $client 'AND-THIS';
16a8962ff246 Tests: upstream_response_length_variable tests, proxy.t merged.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
304
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
305 } else {
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
306
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
307 print $client <<"EOF";
42
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
308 HTTP/1.1 404 Not Found
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
309 Connection: close
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
310
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
311 Oops, '$uri' not found
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
312 EOF
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
83
6e5884419e4a Tests: whitespace cleanup.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
315 close $client;
42
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 }
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
318
7435db149168 Tests: basic proxy tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
319 ###############################################################################