Mercurial > hg > nginx-tests
view http_expect_100_continue.t @ 290:f781b087b7aa
Tests: fixed possible test suite hang on exit.
In some cases (for example, call of global object method in a function), test
suite can hang during exit, because temporary directory holding a pid file is
removed prior to executing global test object desctructor.
The root cause is that the directory removal occurs in the END block (in the
File::Temp package) and the order of executing destructors and END blocks is
not specified in Perl.
The fix is to remove temporary directory in the test object destructor
explicitly and get rid of 'CLEANUP' flag in the tempdir() call. The temporary
directory is removed by the means of rmtree() function, called inside an eval
block to exclude the case when rmtree may abort (some versions are known
to do it).
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 30 May 2013 07:38:23 +0400 |
parents | 6a0d934950bc |
children | 31e2acce8fa4 |
line wrap: on
line source
#!/usr/bin/perl # (C) Maxim Dounin # Tests for Expect: 100-continue support. ############################################################################### use warnings; use strict; use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; use Test::Nginx; ############################################################################### select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(2); $t->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% daemon off; events { } http { %%TEST_GLOBALS_HTTP%% server { listen 127.0.0.1:8080; server_name localhost; location / { proxy_pass http://localhost:8080/local; } location /local { } } } EOF $t->run(); ############################################################################### like(http_100_request('/', '1.1'), qr/100/, 'expect 100 continue'); # From RFC 2616, 8.2.3 Use of the 100 (Continue) Status: # # - An origin server SHOULD NOT send a 100 (Continue) response if # the request message does not include an Expect request-header # field with the "100-continue" expectation, and MUST NOT send a # 100 (Continue) response if such a request comes from an HTTP/1.0 # (or earlier) client. unlike(http_100_request('/', '1.0'), qr/100/, 'no 100 continue via http 1.0'); ############################################################################### sub http_100_request { my ($url, $version) = @_; my $r = http(<<EOF); POST $url HTTP/$version Host: localhost Expect: 100-continue Content-Length: 0 Connection: close EOF } ###############################################################################