Support setting client protocols after initialization#97
Support setting client protocols after initialization#97ThisIsMissEm wants to merge 2 commits intofaye:mainfrom
Conversation
There was a problem hiding this comment.
I'm not sure why this file needs
headers = [start, @custom_headers.merge(@headers).to_s, '']
when Client needs:
headers = [start, @headers.merge(@custom_headers).to_s, '']
|
Hi @ThisIsMissEm 👋 Could you show me an example of how you're using this new method? I'm not sure I understand why you have information that needs to be supplied before |
|
@jcoglan I ended up restructuring my code and starting the driver instantiation later, but you can see what I was doing in: mastodon/mastodon#36025 |
|
So, is this change still needed? In the linked PR, you pass the protocols to the I could imagine wanting this on the server end, where you set the protocols based on some header or other input from the client, but on the client side, the driver is initiating the handshake so there's no other input from the other end to influence the choice of protocols. |
|
Yeah, I originally had something closer to your example code and was getting caught with needing to initialise the driver with auth via subprotocol, now I create the driver on connect, allowing me to defer things So this could be closed |
I'm using this gem for some websocket tests in the Mastodon codebase, where we have support for authentication by abusing websocket subprotocols. Currently it's only possible to set the protocols when you initialize the WebSocket client, but not afterwards before starting the client, this means you have to know the protocols value immediately, not lazily.
This change to add support for setting the protocols after initialization but before start ended up being a bit gnarly, due to the way the headers worked.
I had to split the
set_headerheaders from the@headersbecause the tests all failed due to expecting headers in a specific line order, which became messed up otherwise