diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-03-19 19:03:31 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-03-19 19:03:31 +0300 |
commit | 82bb66993e73d2c4b984700b9fa6bcee6b3f2b2c (patch) | |
tree | 8037c50d8d1deb627700ee26a25409e6fecb86da /test | |
parent | 41c872010a6ba4d5f62a13da3bf2243cb7298476 (diff) | |
download | unit-82bb66993e73d2c4b984700b9fa6bcee6b3f2b2c.tar.gz unit-82bb66993e73d2c4b984700b9fa6bcee6b3f2b2c.tar.bz2 |
Tests: more Perl tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/perl/variables/psgi.pl | 11 | ||||
-rw-r--r-- | test/test_perl_application.py | 28 |
2 files changed, 37 insertions, 2 deletions
diff --git a/test/perl/variables/psgi.pl b/test/perl/variables/psgi.pl index c0a61b67..bed20af8 100644 --- a/test/perl/variables/psgi.pl +++ b/test/perl/variables/psgi.pl @@ -4,6 +4,8 @@ my $app = sub { my $len = int($environ->{'CONTENT_LENGTH'}); $environ->{'psgi.input'}->read(my $body, $len); + my $version = join('', @{$environ->{'psgi.version'}}); + return ['200', [ 'Content-Type' => $environ->{'CONTENT_TYPE'}, 'Content-Length' => $len, @@ -11,6 +13,13 @@ my $app = sub { 'Request-Uri' => $environ->{'REQUEST_URI'}, 'Http-Host' => $environ->{'HTTP_HOST'}, 'Server-Protocol' => $environ->{'SERVER_PROTOCOL'}, - 'Custom-Header' => $environ->{'HTTP_CUSTOM_HEADER'} + 'Custom-Header' => $environ->{'HTTP_CUSTOM_HEADER'}, + 'Psgi-Version' => $version, + 'Psgi-Url-Scheme' => $environ->{'psgi.url_scheme'}, + 'Psgi-Multithread' => $environ->{'psgi.multithread'}, + 'Psgi-Multiprocess' => $environ->{'psgi.multiprocess'}, + 'Psgi-Run-Once' => $environ->{'psgi.run_once'}, + 'Psgi-Nonblocking' => $environ->{'psgi.nonblocking'}, + 'Psgi-Streaming' => $environ->{'psgi.streaming'} ], [$body]]; }; diff --git a/test/test_perl_application.py b/test/test_perl_application.py index bfc82f99..45f8ab33 100644 --- a/test/test_perl_application.py +++ b/test/test_perl_application.py @@ -33,7 +33,14 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl): 'Request-Uri': '/', 'Http-Host': 'localhost', 'Server-Protocol': 'HTTP/1.1', - 'Custom-Header': 'blah' + 'Custom-Header': 'blah', + 'Psgi-Version': '11', + 'Psgi-Url-Scheme': 'http', + 'Psgi-Multithread': '', + 'Psgi-Multiprocess': '1', + 'Psgi-Run-Once': '', + 'Psgi-Nonblocking': '', + 'Psgi-Streaming': '' }, 'headers') self.assertEqual(resp['body'], body, 'body') @@ -126,5 +133,24 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl): self.assertEqual(self.get()['body'], 'body\n', 'body io file') + def test_perl_keepalive_body(self): + self.load('variables') + + (resp, sock) = self.post(headers={ + 'Connection': 'keep-alive', + 'Content-Type': 'text/html', + 'Host': 'localhost' + }, start=True, body='0123456789' * 500) + + self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1') + + resp = self.post(headers={ + 'Connection': 'close', + 'Content-Type': 'text/html', + 'Host': 'localhost' + }, sock=sock, body='0123456789') + + self.assertEqual(resp['body'], '0123456789', 'keep-alive 2') + if __name__ == '__main__': unittest.main() |