Mercurial > hg > nginx-tests
comparison proxy_unix.t @ 804:6b2512f859a0
Tests: style.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 09 Dec 2015 19:16:25 +0300 |
parents | 51d3243a762f |
children | ef6466f77e7c |
comparison
equal
deleted
inserted
replaced
803:aa74b2903227 | 804:6b2512f859a0 |
---|---|
43 server { | 43 server { |
44 listen 127.0.0.1:8080; | 44 listen 127.0.0.1:8080; |
45 server_name localhost; | 45 server_name localhost; |
46 | 46 |
47 location / { | 47 location / { |
48 proxy_pass http://unix:/%%TESTDIR%%/unix.sock; | 48 proxy_pass http://unix:%%TESTDIR%%/unix.sock; |
49 proxy_read_timeout 1s; | 49 proxy_read_timeout 1s; |
50 proxy_connect_timeout 2s; | 50 proxy_connect_timeout 2s; |
51 } | 51 } |
52 | 52 |
53 location /var { | 53 location /var { |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 EOF | 60 EOF |
61 | 61 |
62 my $d = $t->testdir(); | 62 my $path = $t->testdir() . '/unix.sock'; |
63 | 63 |
64 $t->run_daemon(\&http_daemon, $d); | 64 $t->run_daemon(\&http_daemon, $path); |
65 $t->run(); | 65 $t->run(); |
66 | 66 |
67 # wait for unix socket to appear | 67 # wait for unix socket to appear |
68 | 68 |
69 for (1 .. 50) { | 69 for (1 .. 50) { |
70 last if -S "$d/unix.sock"; | 70 last if -S $path; |
71 select undef, undef, undef, 0.1; | 71 select undef, undef, undef, 0.1; |
72 } | 72 } |
73 | 73 |
74 ############################################################################### | 74 ############################################################################### |
75 | 75 |
76 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); | 76 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); |
77 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); | 77 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); |
78 | 78 |
79 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); | 79 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); |
80 | 80 |
81 like(http_get("/var?b=unix:/$d/unix.sock:/"), qr/SEE-THIS/, 'proxy variables'); | 81 like(http_get("/var?b=unix:$path:/"), qr/SEE-THIS/, 'proxy with variables'); |
82 | 82 |
83 ############################################################################### | 83 ############################################################################### |
84 | 84 |
85 sub http_daemon { | 85 sub http_daemon { |
86 my ($d) = @_; | |
87 | |
88 my $server = IO::Socket::UNIX->new( | 86 my $server = IO::Socket::UNIX->new( |
89 Proto => 'tcp', | 87 Proto => 'tcp', |
90 Local => "$d/unix.sock", | 88 Local => shift, |
91 Listen => 5, | 89 Listen => 5, |
92 Reuse => 1 | 90 Reuse => 1 |
93 ) | 91 ) |
94 or die "Can't create listening socket: $!\n"; | 92 or die "Can't create listening socket: $!\n"; |
95 | 93 |