Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with the "protocol" #16

Open
d0n3val opened this issue Aug 26, 2013 · 1 comment
Open

Problems with the "protocol" #16

d0n3val opened this issue Aug 26, 2013 · 1 comment

Comments

@d0n3val
Copy link

d0n3val commented Aug 26, 2013

Hi guys,

I needed to "hack" a line in txws.py to allow chrome to connect via websockets. Basically, this is the header Chrome is sending:

2013-08-27 00:36:58+0200 [WebSocketsProtocol (WebSocketProtocol),0,192.168.2.110] {'Origin': 'http://localhost:50000', 'Upgrade': 'websocket', 'Sec-WebSocket-Extensions': 'x-webkit-deflate-frame', 'Sec-WebSocket-Version': '13', 'Sec-WebSocket-Protocol': 'undefined', 'Host': '192.168.2.109:8081', 'Sec-WebSocket-Key': 'lhmkxWbtMFAN+Y37GCuDvA==', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36', 'Connection': 'Upgrade', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache'}

Since 'Sec-WebSocket-Protocol' == 'undefined' this piece of code breaks:

    # Check whether a codec is needed. WS calls this a "protocol" for
    # reasons I cannot fathom.
    protocol = None
    if "WebSocket-Protocol" in self.headers:
        protocol = self.headers["WebSocket-Protocol"]
    elif "Sec-WebSocket-Protocol" in self.headers:
        protocol = self.headers["Sec-WebSocket-Protocol"]

    if protocol: #HERE I NEED TO ADD and protocol != "undefined":
        if protocol not in encoders or protocol not in decoders:
            log.msg("Couldn't handle WS protocol %s!" % protocol)
            return False
        self.codec = protocol

With this it seem to all work fine. I do not know the code, so let me know if I am doing something terrible here or I was lucky and found a bug ;)

Ric

@MostAwesomeDude
Copy link
Owner

This is a bug in Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants