Explicitly deny text messages

We can't really handle them, but let's respond with an explicit error
rather than "unknown opcode".
This commit is contained in:
Pierre Ossman 2018-10-23 16:31:07 +02:00
parent 6a9e446f8e
commit 8eb5cb0cdc
1 changed files with 2 additions and 0 deletions

View File

@ -571,6 +571,8 @@ class WebSocket(object):
msg = self._partial_msg
self._partial_msg = ''.decode("ascii")
return msg
elif frame["opcode"] == 0x1:
self.shutdown(socket.SHUT_RDWR, 1003, "Unsupported: Text frames are not supported")
elif frame["opcode"] == 0x2:
if self._partial_msg:
self.shutdown(socket.SHUT_RDWR, 1002, "Procotol error: Unexpected new frame")