Mercurial > hg > nginx-tests
comparison proxy.t @ 432:c1269426585d
Tests: test for implicit upstream with IP literal and variable.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 11 Jul 2014 16:37:56 +0400 |
parents | 6fe0459b6668 |
children | a8596c7b33cc |
comparison
equal
deleted
inserted
replaced
431:05c46688b54b | 432:c1269426585d |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(3); | 24 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4); |
25 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | 26 $t->write_file_expand('nginx.conf', <<'EOF'); |
27 | 27 |
28 %%TEST_GLOBALS%% | 28 %%TEST_GLOBALS%% |
29 | 29 |
41 | 41 |
42 location / { | 42 location / { |
43 proxy_pass http://127.0.0.1:8081; | 43 proxy_pass http://127.0.0.1:8081; |
44 proxy_read_timeout 1s; | 44 proxy_read_timeout 1s; |
45 } | 45 } |
46 location /var { | |
47 proxy_pass http://$arg_ip:$arg_port/; | |
48 } | |
46 } | 49 } |
47 } | 50 } |
48 | 51 |
49 EOF | 52 EOF |
50 | 53 |
55 | 58 |
56 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); | 59 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); |
57 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); | 60 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); |
58 | 61 |
59 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); | 62 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); |
63 | |
64 like(http_get('/var?ip=127.0.0.1&port=8081'), qr/SEE-THIS/, | |
65 'proxy url with IP literal and variable'); | |
60 | 66 |
61 ############################################################################### | 67 ############################################################################### |
62 | 68 |
63 sub http_daemon { | 69 sub http_daemon { |
64 my $server = IO::Socket::INET->new( | 70 my $server = IO::Socket::INET->new( |