summaryrefslogtreecommitdiffhomepage
path: root/test/test_settings.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_settings.py')
-rw-r--r--test/test_settings.py68
1 files changed, 63 insertions, 5 deletions
diff --git a/test/test_settings.py b/test/test_settings.py
index ea3cfb99..ad8929f8 100644
--- a/test/test_settings.py
+++ b/test/test_settings.py
@@ -10,6 +10,66 @@ from unit.utils import sysctl
class TestSettings(TestApplicationPython):
prerequisites = {'modules': {'python': 'any'}}
+ def test_settings_large_header_buffer_size(self):
+ self.load('empty')
+
+ def set_buffer_size(size):
+ assert 'success' in self.conf(
+ {'http': {'large_header_buffer_size': size}},
+ 'settings',
+ )
+
+ def header_value(size, expect=200):
+ headers = {'Host': 'a' * (size - 1), 'Connection': 'close'}
+ assert self.get(headers=headers)['status'] == expect
+
+ set_buffer_size(4096)
+ header_value(4096)
+ header_value(4097, 431)
+
+ set_buffer_size(16384)
+ header_value(16384)
+ header_value(16385, 431)
+
+ def test_settings_large_header_buffers(self):
+ self.load('empty')
+
+ def set_buffers(buffers):
+ assert 'success' in self.conf(
+ {'http': {'large_header_buffers': buffers}},
+ 'settings',
+ )
+
+ def big_headers(headers_num, expect=200):
+ headers = {'Host': 'localhost', 'Connection': 'close'}
+
+ for i in range(headers_num):
+ headers['Custom-header-' + str(i)] = 'a' * 8000
+
+ assert self.get(headers=headers)['status'] == expect
+
+ set_buffers(1)
+ big_headers(1)
+ big_headers(2, 431)
+
+ set_buffers(2)
+ big_headers(2)
+ big_headers(3, 431)
+
+ set_buffers(8)
+ big_headers(8)
+ big_headers(9, 431)
+
+ @pytest.mark.skip('not yet')
+ def test_settings_large_header_buffer_invalid(self):
+ def check_error(conf):
+ assert 'error' in self.conf({'http': conf}, 'settings')
+
+ check_error({'large_header_buffer_size': -1})
+ check_error({'large_header_buffer_size': 0})
+ check_error({'large_header_buffers': -1})
+ check_error({'large_header_buffers': 0})
+
def test_settings_header_read_timeout(self):
self.load('empty')
@@ -50,20 +110,18 @@ Connection: close
{'http': {'header_read_timeout': 4}}, 'settings'
)
- (resp, sock) = self.http(
+ sock = self.http(
b"""GET / HTTP/1.1
""",
- start=True,
raw=True,
no_recv=True,
)
time.sleep(2)
- (resp, sock) = self.http(
+ sock = self.http(
b"""Host: localhost
""",
- start=True,
sock=sock,
raw=True,
no_recv=True,
@@ -245,7 +303,7 @@ Connection: close
self.load('empty')
def req():
- _, sock = self.http(b'', start=True, raw=True, no_recv=True)
+ sock = self.http(b'', raw=True, no_recv=True)
time.sleep(3)