diff options
Diffstat (limited to '')
-rw-r--r-- | test/unit/http.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/test/unit/http.py b/test/unit/http.py index 281b27d6..8c71825a 100644 --- a/test/unit/http.py +++ b/test/unit/http.py @@ -17,11 +17,6 @@ class TestHTTP(TestUnit): port = 7080 if 'port' not in kwargs else kwargs['port'] url = '/' if 'url' not in kwargs else kwargs['url'] http = 'HTTP/1.0' if 'http_10' in kwargs else 'HTTP/1.1' - read_buffer_size = ( - 4096 - if 'read_buffer_size' not in kwargs - else kwargs['read_buffer_size'] - ) headers = ( {'Host': 'localhost', 'Connection': 'close'} @@ -101,12 +96,15 @@ class TestHTTP(TestUnit): resp = '' if 'no_recv' not in kwargs: - read_timeout = ( - 30 if 'read_timeout' not in kwargs else kwargs['read_timeout'] - ) - resp = self.recvall( - sock, read_timeout=read_timeout, buff_size=read_buffer_size - ).decode(encoding) + recvall_kwargs = {} + + if 'read_timeout' in kwargs: + recvall_kwargs['read_timeout'] = kwargs['read_timeout'] + + if 'read_buffer_size' in kwargs: + recvall_kwargs['buff_size'] = kwargs['read_buffer_size'] + + resp = self.recvall(sock, **recvall_kwargs).decode(encoding) self.log_in(resp) @@ -174,9 +172,12 @@ class TestHTTP(TestUnit): def put(self, **kwargs): return self.http('PUT', **kwargs) - def recvall(self, sock, read_timeout=30, buff_size=4096): + def recvall(self, sock, **kwargs): + timeout = 60 if 'read_timeout' not in kwargs else kwargs['read_timeout'] + buff_size = 4096 if 'buff_size' not in kwargs else kwargs['buff_size'] + data = b'' - while select.select([sock], [], [], read_timeout)[0]: + while select.select([sock], [], [], timeout)[0]: try: part = sock.recv(buff_size) except: |