Mercurial > hg > ngx_http_upstream_keepalive
diff t/proxy.t @ 33:52ca695446d3
Keepalive: more connection validity checks.
Make sure to not cache connections with errors detected, as well as EOF
already read or pending data present. Call ngx_handle_read_event() for
event methods which need it.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 31 Aug 2011 21:21:14 +0400 |
parents | f3b50effc1d4 |
children |
line wrap: on
line diff
--- a/t/proxy.t +++ b/t/proxy.t @@ -77,7 +77,7 @@ eval { }; plan(skip_all => 'no keepalive patches') if $@; -$t->plan(42); +$t->plan(50); ############################################################################### @@ -199,6 +199,20 @@ like(http_get('/inmemory/complex2'), qr/ like(http_get('/inmemory/chunk01'), qr/set: $/, 'inmemory 0 chunk'); like(http_get('/inmemory/chunk02'), qr/set: $/, 'inmemory 0 chunk 2'); +# closed connection tests + +like(http_get('/buffered/closed1'), qr/200 OK/, 'buffered closed 1'); +like(http_get('/buffered/closed2'), qr/200 OK/, 'buffered closed 2'); +like(http_get('/unbuffered/closed1'), qr/200 OK/, 'unbuffered closed 1'); +like(http_get('/unbuffered/closed2'), qr/200 OK/, 'unbuffered closed 2'); +like(http_get('/inmemory/closed1'), qr/200 OK/, 'inmemory closed 1'); +like(http_get('/inmemory/closed2'), qr/200 OK/, 'inmemory closed 2'); + +# check for errors, shouldn't be any + +like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); +like(`grep -F '[error]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no errors'); + ############################################################################### sub http_daemon { @@ -316,6 +330,16 @@ sub http_daemon { "0" . CRLF . CRLF unless $headers =~ /^HEAD/i; + } elsif ($uri =~ m/closed/) { + print $client + "HTTP/1.1 200 OK" . CRLF . + "X-Request: $rcount" . CRLF . + "X-Connection: $ccount" . CRLF . + "Connection: close" . CRLF . + "Content-Length: 12" . CRLF . CRLF . + "0123456789" . CRLF; + last; + } else { print $client "HTTP/1.1 404 Not Found" . CRLF .