xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2104: websockify-latest.patch

File websockify-latest.patch, 2.2 KB (added by Antoine Martin, 2 years ago)

some changes required to run against the latest websockify

  • xpra/server/websocket.py

     
    6161                log.warn("Warning: %s", x)
    6262
    6363
    64 WEBSOCKET_TCP_NODELAY = envbool("WEBSOCKET_TCP_NODELAY", True)
    65 WEBSOCKET_TCP_KEEPALIVE = envbool("WEBSOCKET_TCP_KEEPALIVE", True)
    6664WEBSOCKET_DEBUG = envbool("XPRA_WEBSOCKET_DEBUG", False)
    67 
    6865HTTP_ACCEPT_ENCODING = os.environ.get("XPRA_HTTP_ACCEPT_ENCODING", "br,gzip").split(",")
    6966
    7067
    7168class WSRequestHandler(WebSocketRequestHandler):
    7269
    73     disable_nagle_algorithm = WEBSOCKET_TCP_NODELAY
    74     keep_alive = WEBSOCKET_TCP_KEEPALIVE
    7570    server_version = "Xpra-WebSockify"
    7671
    7772    http_headers_cache = {}
     
    128123            log.error(fmt, *args)
    129124
    130125    def log_message(self, fmt, *args):
    131         #log.warn("%s", (fmt, args))
    132126        log(fmt, *args)
    133127
    134128    def print_traffic(self, token="."):
     
    196190            log.error("Error processing POST request", exc_info=True)
    197191
    198192    def do_GET(self):
     193        if self.only_upgrade or (self.headers.get('upgrade') and
     194            self.headers.get('upgrade').lower() == 'websocket'):
     195            try:
     196                #>0.8
     197                self.handle_upgrade()
     198            except AttributeError:
     199                #<=0.8
     200                self.handle_websocket()
     201            return
    199202        self.handle_request()
    200203
    201204    def handle_request(self):
    202         """
    203         Calls handle_websocket(). If unsuccessful,
    204         and web server is enabled, SimpleHTTPRequestHandler.do_GET will be called.
    205         """
    206         if not self.handle_websocket():
    207             if self.only_upgrade:
    208                 self.send_error(405, "Method Not Allowed")
    209             else:
    210                 content = self.send_head()
    211                 if content:
    212                     self.wfile.write(content)
     205        if self.only_upgrade:
     206            self.send_error(405, "Method Not Allowed")
     207        else:
     208            content = self.send_head()
     209            if content:
     210                self.wfile.write(content)
     211            #self.wfile.close()
    213212
    214213    def do_HEAD(self):
    215214        if self.only_upgrade: