Example #1
0
 def __init__(self,
              sock,
              addr,
              new_websocket_client,
              web_root="/usr/share/xpra/www/",
              http_headers_dir="/usr/share/xpra/http-headers",
              script_paths={}):
     self.new_websocket_client = new_websocket_client
     self.only_upgrade = WEBSOCKET_ONLY_UPGRADE
     HTTPRequestHandler.__init__(self, sock, addr, web_root,
                                 http_headers_dir, script_paths)
Example #2
0
 def do_GET(self):
     upgrade_requested = (self.headers.get('upgrade') or "").lower() == 'websocket'
     if self.only_upgrade or upgrade_requested:
         if not upgrade_requested:
             self.send_error(403, "only websocket connections are allowed")
             return
         try:
             self.handle_websocket()
         except Exception as e:
             log("do_GET()", exc_info=True)
             log.error("Error: cannot handle websocket upgrade:")
             log.error(" %s", e)
             self.send_error(403, "failed to handle websocket: %s" % e)
         return
     HTTPRequestHandler.do_GET(self)
Example #3
0
 def handle_request(self):
     if self.only_upgrade:
         self.send_error(405, "Method Not Allowed")
         return
     HTTPRequestHandler.handle_request(self)
Example #4
0
 def do_HEAD(self):
     if self.only_upgrade:
         self.send_error(405, "Method Not Allowed")
         return
     HTTPRequestHandler.do_HEAD(self)