diff options
author | Andrei Belov <defan@nginx.com> | 2020-04-16 18:27:26 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-04-16 18:27:26 +0300 |
commit | 74f32d26b91f49d3392605e81c1597b375890b60 (patch) | |
tree | adfc67dfc86461441bde65512f745ce27bd6ea28 /test/unit/applications/websockets.py | |
parent | 2ff9df10ef1df43c935c870175e52473dad2c21a (diff) | |
parent | 9877087756144d3bdf343d0d4e91e1efbcc62c93 (diff) | |
download | unit-74f32d26b91f49d3392605e81c1597b375890b60.tar.gz unit-74f32d26b91f49d3392605e81c1597b375890b60.tar.bz2 |
Merged with the default branch.1.17.0-1
Diffstat (limited to 'test/unit/applications/websockets.py')
-rw-r--r-- | test/unit/applications/websockets.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test/unit/applications/websockets.py b/test/unit/applications/websockets.py index ef16f433..fc15e8e4 100644 --- a/test/unit/applications/websockets.py +++ b/test/unit/applications/websockets.py @@ -52,7 +52,11 @@ class TestApplicationWebsocket(TestApplicationProto): ) resp = '' - while select.select([sock], [], [], 30)[0]: + while True: + rlist = select.select([sock], [], [], 60)[0] + if not rlist: + self.fail('Can\'t read response from server.') + resp += sock.recv(4096).decode() if ( @@ -70,10 +74,18 @@ class TestApplicationWebsocket(TestApplicationProto): def serialize_close(self, code=1000, reason=''): return struct.pack('!H', code) + reason.encode('utf-8') - def frame_read(self, sock, read_timeout=30): + def frame_read(self, sock, read_timeout=60): def recv_bytes(sock, bytes): data = b'' - while select.select([sock], [], [], read_timeout)[0]: + while True: + rlist = select.select([sock], [], [], read_timeout)[0] + if not rlist: + # For all current cases if the "read_timeout" was changed + # than test do not expect to get a response from server. + if read_timeout == 60: + self.fail('Can\'t read response from server.') + break + data += sock.recv(bytes - len(data)) if len(data) == bytes: @@ -221,7 +233,7 @@ class TestApplicationWebsocket(TestApplicationProto): op_code = self.OP_CONT pos = end - def message_read(self, sock, read_timeout=10): + def message_read(self, sock, read_timeout=60): frame = self.frame_read(sock, read_timeout=read_timeout) while not frame['fin']: |