tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

delayed-passive-close_wsh.py (785B)


      1 #!/usr/bin/python
      2 from pywebsocket3 import common
      3 import time
      4 
      5 def web_socket_do_extra_handshake(request):
      6    pass
      7 
      8 
      9 def web_socket_transfer_data(request):
     10    # Wait for the close frame to arrive.
     11    request.ws_stream.receive_message()
     12 
     13 
     14 def web_socket_passive_closing_handshake(request):
     15    # Echo close status code and reason
     16    code, reason = request.ws_close_code, request.ws_close_reason
     17 
     18    # No status received is a reserved pseudo code representing an empty code,
     19    # so echo back an empty code in this case.
     20    if code == common.STATUS_NO_STATUS_RECEIVED:
     21        code = None
     22 
     23    # The browser may error the connection if the closing handshake takes too
     24    # long, but hopefully no browser will have a timeout this short.
     25    time.sleep(1)
     26 
     27    return code, reason