You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These changes can all be done in a backwards compatible way. I'm willing to make a PR if I can get buy in on the concept. Let me know what you think.
[1] The event does include the Sec-WebSocket-Extensions headers, but these headers need to be parsed and that's best done within wsproto.
[2] These handshake features will be consumed downstream in python-trio/trio-websocket#4
Ideally, I would like to keep the handshake part as independent as possible from the actual WS communication.
At least for most of my own use cases, I would like to instantiate a WSConn object without needing to touch HTTP requests, responses, or headers. So the WSConn ctor should be able to take all args that it ever needs to result in a fully working, fully initialized state.
Extensions are exposed in the ConnectionRequested event.
Sounds like a reasonable thing to do! Happy to merge a PR!
(but also, see below)
Add extensions argument to accept() method. This would take a list of extensions in the same format as the connection's current self._extensions list.
Currently, wsproto keeps a list of "active" extensions, and then calls "accept" on each one to figure out if the header should be set. @mehaase: do you have a use case that does not fit in with this approach? Meaning, do you have extensions that DO NOT live as wsproto-extension object and are therefore not registered?
Currently, wsproto keeps a list of "active" extensions, and then calls "accept" on each one to figure out if the header should be set. @mehaase: do you have a use case that does not fit in with this approach? Meaning, do you have extensions that DO NOT live as wsproto-extension object and are therefore not registered?
No, actually I don't have any other extensions at all. I suggested this change because extensions can be negotiated in the handshake, and the caller might want fine-grained control over which extensions are enabled depending on handshake data. I don't have a specific use case in mind; just want to keep it flexible.
Activity
Kriechi commentedon Oct 19, 2018
Ideally, I would like to keep the handshake part as independent as possible from the actual WS communication.
At least for most of my own use cases, I would like to instantiate a WSConn object without needing to touch HTTP requests, responses, or headers. So the WSConn ctor should be able to take all args that it ever needs to result in a fully working, fully initialized state.
Sounds like a reasonable thing to do! Happy to merge a PR!
(but also, see below)
Currently, wsproto keeps a list of "active" extensions, and then calls "accept" on each one to figure out if the header should be set. @mehaase: do you have a use case that does not fit in with this approach? Meaning, do you have extensions that DO NOT live as wsproto-extension object and are therefore not registered?
mehaase commentedon Oct 25, 2018
No, actually I don't have any other extensions at all. I suggested this change because extensions can be negotiated in the handshake, and the caller might want fine-grained control over which extensions are enabled depending on handshake data. I don't have a specific use case in mind; just want to keep it flexible.
pgjones commentedon Jan 6, 2019
@mehaase I think all of this is now possible,
So can this be closed?
mehaase commentedon Jan 7, 2019
This is great, @pgjones, thanks!