diff options
author | Pierre Ossman <ossman@cendio.se> | 2020-09-30 14:51:07 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2020-09-30 14:51:07 +0200 |
commit | d72ace2ae6cbc3785401c814abbc282031bf6293 (patch) | |
tree | 2511162e8c3cf48c980a1ab475ae5364ea3d7833 /websockify | |
parent | 536a548db52828ab1c073193ed12cc6dc16964e5 (diff) | |
download | websockify-d72ace2ae6cbc3785401c814abbc282031bf6293.tar.gz |
Allow sending empty messages
This is perfectly valid in the protocol, and may be meningful to some
applications. However send() is still stream oriented so it will ignore
an empty buffer.
Diffstat (limited to 'websockify')
-rw-r--r-- | websockify/websocket.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/websockify/websocket.py b/websockify/websocket.py index 03a52f0..a9f85a9 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -421,6 +421,9 @@ class WebSocket(object): WebSocketWantWriteError can be raised if there is insufficient space in the underlying socket. """ + if len(bytes) == 0: + return 0 + return self.sendmsg(bytes) def sendmsg(self, msg): @@ -435,8 +438,7 @@ class WebSocket(object): """ if not self._sent_close: # Only called to flush? - if msg: - self._sendmsg(0x2, msg) + self._sendmsg(0x2, msg) self._flush() return len(msg) |