Adding Authorization or Headers with Cro::WebSocket::Client?

265 Views Asked by At

I'm using Cro HTTP Authentication/Authorization/Sessions very successfully with HTTP routes.

Then I added a route that creates a web-socket using Cro::HTTP::Router::WebSocket, and I can connect to it with Cro::WebSocket::Client and everything works fine.

Now I want to control access to the websocket, so I add a Cro::HTTP::Auth parameter. Works great. Now the the client gets a 401 Unauthorized as expected.

Next step, how do I open the door?

With Cro::HTTP::Client, I can pass in an Authorization header, or even pass in the auth option. How do I do that with Cro::WebSocket::Client?

I'm very new to WebSocket, so I don't even know if this is the right way to do things like this, but it seems like the Cro::WebSocket::Client connect method should take a headers named option that gets extra headers that get passed along.

1

There are 1 best solutions below

0
On

The mentioned patch from titsuki was merged by Jonathan Worthington with commit 2593e21 on Oct 14, 2018