# HG changeset patch # User Andrey Zelenkov # Date 1454333765 -10800 # Node ID ef6466f77e7c61017663c3b35eb020a7ced518f7 # Parent 68a6678abae263a4b767f78afc6a444791b84af1 Tests: added proxy test with implicit upstream over unix socket. diff -r 68a6678abae2 -r ef6466f77e7c proxy_unix.t --- a/proxy_unix.t Fri Jan 29 16:12:42 2016 +0300 +++ b/proxy_unix.t Mon Feb 01 16:36:05 2016 +0300 @@ -26,7 +26,7 @@ eval { require IO::Socket::UNIX; }; plan(skip_all => 'IO::Socket::UNIX not installed') if $@; -my $t = Test::Nginx->new()->has(qw/http proxy unix/)->plan(4); +my $t = Test::Nginx->new()->has(qw/http proxy unix/)->plan(5); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -40,6 +40,10 @@ http { %%TEST_GLOBALS_HTTP%% + upstream u { + server unix:%%TESTDIR%%/unix.sock; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -54,6 +58,11 @@ proxy_pass http://$arg_b; proxy_read_timeout 1s; } + + location /u { + proxy_pass http://u; + proxy_read_timeout 1s; + } } } @@ -80,6 +89,8 @@ like(http_get("/var?b=unix:$path:/"), qr/SEE-THIS/, 'proxy with variables'); +like(http_get('/u'), qr/SEE-THIS/, 'proxy implicit upstream'); + ############################################################################### sub http_daemon { @@ -106,7 +117,7 @@ $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; - if ($uri eq '/') { + if (grep { $uri eq $_ } ('/', '/u')) { print $client <<'EOF'; HTTP/1.1 200 OK Connection: close