# 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 --git a/proxy_unix.t b/proxy_unix.t --- a/proxy_unix.t +++ b/proxy_unix.t @@ -26,7 +26,7 @@ select STDOUT; $| = 1; 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 @@ events { 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 @@ http { proxy_pass http://$arg_b; proxy_read_timeout 1s; } + + location /u { + proxy_pass http://u; + proxy_read_timeout 1s; + } } } @@ -80,6 +89,8 @@ unlike(http_head('/'), qr/SEE-THIS/, 'pr 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 @@ sub http_daemon { $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