websocket: fix empty frame with fin=1

This commit is contained in:
Thomas Kriechbaumer 2016-11-29 21:00:42 +01:00
parent 34bf3a2496
commit 5ee192b758
1 changed files with 9 additions and 1 deletions

View File

@ -82,7 +82,15 @@ class WebSocketLayer(base.Layer):
mask=(False if is_server else 1),
masking_key=(b'' if is_server else os.urandom(4))) for i in chunks
]
frms[-1].header.fin = 1
if len(frms) > 0:
frms[-1].header.fin = True
else:
frms.append(websockets.Frame(
fin=True,
opcode=frame.header.opcode,
mask=(False if is_server else 1),
masking_key=(b'' if is_server else os.urandom(4))))
for frm in frms:
other_conn.send(bytes(frm))