summaryrefslogtreecommitdiffhomepage
path: root/test/test_http_header.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_http_header.py')
-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()