stalefruits / gniazdo

A WebSocket client for Clojure
Apache License 2.0
210 stars 38 forks source link

Send headers or params, with send-msg? #34

Open twashing opened 4 years ago

twashing commented 4 years ago

I'm taking a look at the spec for WS data frames. And I just see a way to pass a generic payload.

Is there any way to send headers or params, along with send-msg? I don't see one. But I'm hoping I'm wrong.

jstepien commented 4 years ago

Good question. We can send headers when connecting, but I also don't see a way to do it on a per-message basis. send-msg relies on RemoteEndpoint, which doesn't appear to expose the right interface. Unless I'm missing something in Jetty's API. Happy to accept a patch if you find a solution.

twashing commented 4 years ago

Hmm, that's interesting. I saw that you can pass in headers and params at connection time.

But I don't know enough about Websocket's message lifecycle to see a way to do it through send-msg. From the WS RFC , I don't see a way to pass any HTTP header or params.

Buuut, I was able to access the context's request, which had the original connection headers. My code has access to the original headers (in org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest). That's going to be dependent on your server's WS implementation. But I'm guessing you'll have to do some kind of similar gymnastics.