Echo close reason and close code

Set code to None if it is STATUS_NO_STATUS_RECEIVED, which should not be
sent across the wire.
This commit is contained in:
James Sanders 2016-01-11 20:04:11 -07:00
parent 175b3c2d27
commit a640b9aaea

View file

@ -1,5 +1,6 @@
#!/usr/bin/python
from mod_pywebsocket import msgutil
from mod_pywebsocket import common
_GOODBYE_MESSAGE = u'Goodbye'
@ -23,3 +24,13 @@ def web_socket_transfer_data(request):
else:
request.ws_stream.send_message(line, binary=True)
def web_socket_passive_closing_handshake(request):
# Echo close status code and reason
code, reason = request.ws_close_code, request.ws_close_reason
# No status received is a reserved pseudo code representing an empty code,
# so echo back an empty code in this case.
if code == common.STATUS_NO_STATUS_RECEIVED:
code = None
return code, reason