summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2019-02-14 16:09:58 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2019-02-14 16:09:58 +0300
commitab40732c0886b979090da6245cc1a7f0ba52de49 (patch)
tree61e4b0ad433b6185546a55b0e59a422c459aa9bc /test
parent0e5aaf60d4ca2da509a6a73bebe71139f8aae306 (diff)
downloadunit-ab40732c0886b979090da6245cc1a7f0ba52de49.tar.gz
unit-ab40732c0886b979090da6245cc1a7f0ba52de49.tar.bz2
Tests: added tests for "Content-Length" header.
Diffstat (limited to '')
-rw-r--r--test/test_http_header.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/test_http_header.py b/test/test_http_header.py
index b850831d..7894c94e 100644
--- a/test/test_http_header.py
+++ b/test/test_http_header.py
@@ -162,5 +162,51 @@ a
self.assertEqual(resp['status'], 200, 'transfer encoding chunked')
+ def test_http_header_content_length_big(self):
+ self.load('empty')
+
+ self.assertEqual(self.post(headers={
+ 'Content-Length': str(2 ** 64),
+ 'Connection': 'close',
+ 'Host': 'localhost'
+ }, body='X' * 1000)['status'], 400, 'Content-Length big')
+
+ def test_http_header_content_length_negative(self):
+ self.load('empty')
+
+ self.assertEqual(self.post(headers={
+ 'Content-Length': '-100',
+ 'Connection': 'close',
+ 'Host': 'localhost'
+ }, body='X' * 1000)['status'], 400, 'Content-Length negative')
+
+ def test_http_header_content_length_text(self):
+ self.load('empty')
+
+ self.assertEqual(self.post(headers={
+ 'Content-Length': 'blah',
+ 'Connection': 'close',
+ 'Host': 'localhost'
+ }, body='X' * 1000)['status'], 400, 'Content-Length text')
+
+ def test_http_header_content_length_multiple_values(self):
+ self.load('empty')
+
+ self.assertEqual(self.post(headers={
+ 'Content-Length': '41, 42',
+ 'Connection': 'close',
+ 'Host': 'localhost'
+ }, body='X' * 1000)['status'], 400, 'Content-Length multiple value')
+
+ @unittest.expectedFailure
+ def test_http_header_content_length_multiple_fields(self):
+ self.load('empty')
+
+ self.assertEqual(self.post(headers={
+ 'Content-Length': ['41', '42'],
+ 'Connection': 'close',
+ 'Host': 'localhost'
+ }, body='X' * 1000)['status'], 400, 'Content-Length multiple fields')
+
if __name__ == '__main__':
TestUnitHTTPHeader.main()