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

Error in handling protocol #228

Open
Seraphli opened this issue Aug 29, 2017 · 1 comment
Open

Error in handling protocol #228

Seraphli opened this issue Aug 29, 2017 · 1 comment

Comments

@Seraphli
Copy link
Contributor

elif header == 'sec-websocket-protocol':
protocols = ','.join(value)
elif header == 'sec-websocket-extensions':
extensions = ','.join(value)

The value will be b'chat' if using same handshake information like the one on wiki.
So using join will result in TypeError: sequence item 0: expected str instance, int found.
I notice this code haven't been changed for 5 years. And I try to find an example of cherrypy and ws4py which contain a setting of Sec-WebSocket-Protocol for websocket server. But I can't find any. I also check the handshake information sent by simple example, and it didn't contain a Sec-WebSocket-Protocol header.
A more astonishing thing is there is no test about Sec-WebSocket-Protocol in test_client.py.

@Seraphli
Copy link
Contributor Author

I think it should be fixed like this

            elif header == b'sec-websocket-protocol':
                protocols.append(value.decode('utf-8'))

            elif header == b'sec-websocket-extensions':
                extensions.append(value.decode('utf-8'))

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

1 participant