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.
This commit is contained in:
parent
536a548db5
commit
d72ace2ae6
|
@ -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,7 +438,6 @@ class WebSocket(object):
|
|||
"""
|
||||
if not self._sent_close:
|
||||
# Only called to flush?
|
||||
if msg:
|
||||
self._sendmsg(0x2, msg)
|
||||
|
||||
self._flush()
|
||||
|
|
Loading…
Reference in New Issue