trio-websocket
trio-websocket copied to clipboard
Connection upgrade example
Would be great to have an example of upgrading a connection from http, based on the trio-server example in h11.
Thanks for all the feedback! I am going to start tackling these issues today.
I'm taking a look at h11's example trio-server.py. I think what you're asking for here is a documented example of the following:
- A web server (like h11's
trio-server.py) receives a new connection. - It processes the WebSocket HTTP upgrade request.
- It wraps the resulting stream in a
WebSocketConnection.
Is this right?
It's not clear to me if wsproto supports this: it looks like it always wants to do the HTTP upgrade request. To make this work, I think we would need a way for wsproto to skip the upgrade request and obtain that metadata (like host header) from somewhere else. Thoughts?
It looks like this behavior was submitted to wsproto but is currently on hold: https://github.com/python-hyper/wsproto/pull/37