Mercurial > hg > nginx-tests
annotate proxy_cache_lock_age.t @ 540:481d705b8610
Tests: SSL support in mail backends.
Socket is now embedded into every mail module.
Socket methods are wrapped where appropriate.
The new "SSL" extra flag specifies to accept connection over SSL.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 03 Apr 2015 00:11:38 +0300 |
parents | 071e8941e3bf |
children | 907e89fba9c3 |
rev | line source |
---|---|
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http proxy cache lock aged. |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use IO::Select; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 my $t = Test::Nginx->new()->has(qw/http proxy cache/) |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 ->write_file_expand('nginx.conf', <<'EOF'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 events { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 http { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 %%TEST_GLOBALS_HTTP%% |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
501
diff
changeset
|
43 keys_zone=NAME:1m; |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 listen 127.0.0.1:8080; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server_name localhost; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 proxy_pass http://127.0.0.1:8081; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_cache NAME; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 proxy_cache_lock on; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_cache_lock_age 100ms; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 $t->run_daemon(\&http_daemon, 8081); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 $t->try_run('no proxy_cache_lock_age')->plan(2); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 $t->waitforsocket('127.0.0.1:8081'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 my $s = http_get('/', start => 1); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 like(http_get('/'), qr/request 2/, 'request'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 like(http_get('/'), qr/request 2/, 'request cached'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 http_get('/close'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 sub http_daemon { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 my (@ports) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 my @socks; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 for my $port (@ports) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 my $server = IO::Socket::INET->new( |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 Proto => 'tcp', |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 LocalHost => "127.0.0.1:$port", |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 Listen => 5, |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 Reuse => 1 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 ) |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 or die "Can't create listening socket: $!\n"; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 push @socks, $server; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $sel = IO::Select->new(@socks); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 my $num = 0; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 my $s; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 local $SIG{PIPE} = 'IGNORE'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 while (my @ready = $sel->can_read) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 foreach my $fh (@ready) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 if (grep $_ == $fh, @socks) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 my $new = $fh->accept; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $new->autoflush(1); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 $sel->add($new); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 } elsif (process_socket($fh, \$num, \$s)) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 $sel->remove($fh); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 $fh->close; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 # Returns true to close connection |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 sub process_socket { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 my ($client, $num, $s) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 my $headers = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 my $uri = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 while (<$client>) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 $headers .= $_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 last if (/^\x0d?\x0a?$/); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 return 1 if $headers eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 return 1 if $uri eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 # finish a previously saved socket |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 close $$s if $uri eq '/close'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 $$num++; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 print $client <<EOF; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 HTTP/1.1 200 OK |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 Cache-Control: max-age=300 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 Connection: close |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 request $$num |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 # save socket and wait |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 if ($$num == 1) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 $$s = $client; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 return 0; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 return 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ############################################################################### |