diff options
author | Max Romanov <max.romanov@nginx.com> | 2021-01-28 17:13:52 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2021-01-28 17:13:52 +0300 |
commit | e4e444b82701de0c984a72eb9c2657f72d7171ae (patch) | |
tree | 764370b602b981e3c50af3b1b786321e54c64ac0 /test/test_asgi_websockets.py | |
parent | 3855f1c032cb52f4e8f370f639d259b7cc313939 (diff) | |
download | unit-e4e444b82701de0c984a72eb9c2657f72d7171ae.tar.gz unit-e4e444b82701de0c984a72eb9c2657f72d7171ae.tar.bz2 |
Router: fixing crash after WebSocket processing.
After WebSocket processing, the application port was released with incorrect
reason ("got request"), unnecessarily decrementing the active request counter.
The assertion was triggered only on application removal; a test was added
for this case.
Diffstat (limited to 'test/test_asgi_websockets.py')
-rw-r--r-- | test/test_asgi_websockets.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 7c9ec555..6121fcc5 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -63,6 +63,9 @@ class TestASGIWebsockets(TestApplicationPython): key ), 'key' + # remove "mirror" application + self.load('websockets/subprotocol') + def test_asgi_websockets_subprotocol(self): self.load('websockets/subprotocol') @@ -92,6 +95,27 @@ class TestASGIWebsockets(TestApplicationPython): sock.close() + def test_asgi_websockets_mirror_app_change(self): + self.load('websockets/mirror') + + message = 'blah' + + _, sock, _ = self.ws.upgrade() + + self.ws.frame_write(sock, self.ws.OP_TEXT, message) + frame = self.ws.frame_read(sock) + + assert message == frame['data'].decode('utf-8'), 'mirror' + + self.load('websockets/subprotocol') + + self.ws.frame_write(sock, self.ws.OP_TEXT, message) + frame = self.ws.frame_read(sock) + + assert message == frame['data'].decode('utf-8'), 'mirror 2' + + sock.close() + def test_asgi_websockets_no_mask(self): self.load('websockets/mirror') |