summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications/websockets.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2019-11-13 18:11:24 +0300
committerAndrei Zeliankou <zelenkov@nginx.com>2019-11-13 18:11:24 +0300
commit5452ee458d2c764569213266362fb636114adbc2 (patch)
treea3fa05f63f141b94e40a43e9c93061c4dd7afe70 /test/unit/applications/websockets.py
parent45d75ee2cb33d38f64ca2ac5d871fa0cc2f1bcde (diff)
downloadunit-5452ee458d2c764569213266362fb636114adbc2.tar.gz
unit-5452ee458d2c764569213266362fb636114adbc2.tar.bz2
Tests: fixed websocket tests.
Diffstat (limited to 'test/unit/applications/websockets.py')
-rw-r--r--test/unit/applications/websockets.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/unit/applications/websockets.py b/test/unit/applications/websockets.py
index 5f78498c..ef16f433 100644
--- a/test/unit/applications/websockets.py
+++ b/test/unit/applications/websockets.py
@@ -31,17 +31,22 @@ class TestApplicationWebsocket(TestApplicationProto):
sha1 = hashlib.sha1((key + GUID).encode()).digest()
return base64.b64encode(sha1).decode()
- def upgrade(self):
- key = self.key()
- _, sock = self.get(
- headers={
+ def upgrade(self, headers=None):
+ key = None
+
+ if headers is None:
+ key = self.key()
+ headers = {
'Host': 'localhost',
'Upgrade': 'websocket',
'Connection': 'Upgrade',
'Sec-WebSocket-Key': key,
'Sec-WebSocket-Protocol': 'chat',
'Sec-WebSocket-Version': 13,
- },
+ }
+
+ _, sock = self.get(
+ headers=headers,
no_recv=True,
start=True,
)