Mercurial > hg > nginx-tests
annotate proxy_redirect.t @ 955:b8948aecba12
Tests: HTTP/2 request body Content-Length tests in proxied request.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Jun 2016 20:46:10 +0300 |
parents | e9064d691790 |
children | 882267679006 |
rev | line source |
---|---|
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
2 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
4 # (C) Valentin Bartenev |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
5 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
6 # Tests for the proxy_redirect directive. |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
7 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
8 ############################################################################### |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
9 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
10 use warnings; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
11 use strict; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
12 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
13 use Test::More; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
14 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
16 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
19 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
20 ############################################################################### |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
21 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
24 |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(15); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
26 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
28 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
30 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
31 daemon off; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
32 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
33 events { |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
34 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
35 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
36 http { |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
38 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
39 server { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
40 listen 127.0.0.1:%%PORT_0%%; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
41 server_name localhost; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
42 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
43 location / { |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
44 set $some_var var_here; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
45 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
46 proxy_pass http://127.0.0.1:%%PORT_1%%; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
47 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
48 proxy_redirect http://127.0.0.1:%%PORT_1%%/var_in_second/ |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
49 /$some_var/; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
50 proxy_redirect http://127.0.0.1:%%PORT_1%%/$some_var/ /replaced/; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
51 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
52 proxy_redirect ~^(.+)/regex_w_([^/]+) $1/$2/test.html; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
53 proxy_redirect ~*re+gexp? /replaced/test.html; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
54 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
55 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
56 location /expl_default/ { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
57 proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
58 proxy_redirect wrong wrong; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
59 proxy_redirect default; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
60 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
61 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
62 location /impl_default/ { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
63 proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
64 } |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
65 |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
66 location /off/ { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
67 proxy_pass http://127.0.0.1:%%PORT_1%%/; |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
68 proxy_redirect off; |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
69 |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
70 location /off/on/ { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
71 proxy_pass http://127.0.0.1:%%PORT_1%%; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
72 proxy_redirect http://127.0.0.1:%%PORT_1%%/off/ /; |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
73 |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
74 location /off/on/on/ { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
75 proxy_pass http://127.0.0.1:%%PORT_1%%; |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
76 } |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
77 } |
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
78 } |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
79 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
80 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
81 server { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
82 listen 127.0.0.1:%%PORT_1%%; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
83 server_name localhost; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
84 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
85 location / { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
86 add_header Refresh "7; url=http://127.0.0.1:%%PORT_1%%$uri"; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
87 return http://127.0.0.1:%%PORT_1%%$uri; |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
88 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
89 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
90 } |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
91 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
92 EOF |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
93 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
94 $t->run(); |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
95 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
96 ############################################################################### |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
97 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
98 my ($p0, $p1) = (port(0), port(1)); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
99 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
100 is(http_get_location("http://127.0.0.1:$p0/impl_default/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
101 "http://127.0.0.1:$p0/impl_default/test.html", 'implicit default'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
102 is(http_get_location("http://127.0.0.1:$p0/expl_default/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
103 "http://127.0.0.1:$p0/expl_default/test.html", 'explicit default'); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
104 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
105 is(http_get_refresh("http://127.0.0.1:$p0/impl_default/test.html"), |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
106 '7; url=/impl_default/test.html', 'implicit default (refresh)'); |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
107 is(http_get_refresh("http://127.0.0.1:$p0/expl_default/test.html"), |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
108 '7; url=/expl_default/test.html', 'explicit default (refresh)'); |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
109 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
110 is(http_get_location("http://127.0.0.1:$p0/var_in_second/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
111 "http://127.0.0.1:$p0/var_here/test.html", 'variable in second arg'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
112 is(http_get_refresh("http://127.0.0.1:$p0/var_in_second/test.html"), |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
113 '7; url=/var_here/test.html', 'variable in second arg (refresh)'); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
114 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
115 is(http_get_location("http://127.0.0.1:$p0/off/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
116 "http://127.0.0.1:$p1/test.html", 'rewrite off'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
117 is(http_get_location("http://127.0.0.1:$p0/off/on/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
118 "http://127.0.0.1:$p0/on/test.html", 'rewrite off overwrite'); |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
119 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
120 is(http_get_location("http://127.0.0.1:$p0/off/on/on/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
121 "http://127.0.0.1:$p0/on/on/test.html", 'rewrite inheritance'); |
196
3f59e6a843bd
Tests: proxy_redirect off inheritance.
Valentin Bartenev <ne@vbart.ru>
parents:
193
diff
changeset
|
122 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
123 is(http_get_location("http://127.0.0.1:$p0/var_here/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
124 "http://127.0.0.1:$p0/replaced/test.html", 'variable in first arg'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
125 is(http_get_refresh("http://127.0.0.1:$p0/var_here/test.html"), |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
126 '7; url=/replaced/test.html', 'variable in first arg (refresh)'); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
127 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
128 is(http_get_location("http://127.0.0.1:$p0/ReeegEX/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
129 "http://127.0.0.1:$p0/replaced/test.html", 'caseless regexp'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
130 is(http_get_location("http://127.0.0.1:$p0/regex_w_captures/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
131 "http://127.0.0.1:$p1/captures/test.html", 'regexp w/captures'); |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
132 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
133 is(http_get_refresh("http://127.0.0.1:$p0/ReeegEX/test.html"), |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
134 '7; url=/replaced/test.html', 'caseless regexp (refresh)'); |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
135 is(http_get_refresh("http://127.0.0.1:$p0/regex_w_captures/test.html"), |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
224
diff
changeset
|
136 "7; url=http://127.0.0.1:$p1/captures/test.html", |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
137 'regexp w/captures (refresh)'); |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
138 |
186
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
139 ############################################################################### |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
140 |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
141 sub http_get_location { |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
142 my ($url) = @_; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
143 http_get($url) =~ /^Location:\s(.+?)\x0d?$/mi; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
144 return $1; |
1613a63b5100
Tests: added proxy_redirect tests.
Valentin Bartenev <ne@vbart.ru>
parents:
diff
changeset
|
145 } |
193
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
146 |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
147 sub http_get_refresh { |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
148 my ($url) = @_; |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
149 http_get($url) =~ /^Refresh:\s(.+?)\x0d?$/mi; |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
150 return $1; |
50063559d85a
Tests: proxy_redirect and Refresh header.
Valentin Bartenev <ne@vbart.ru>
parents:
186
diff
changeset
|
151 } |