softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.46k stars 310 forks source link

Websocket Subprotocol support #935

Open barthorre opened 3 years ago

barthorre commented 3 years ago

It seems there is no support for adding subprotocols to a websocket request.

For Akka backend you can customize the websocket request directly to solve the issue:

AkkaHttpBackend(customizeWebsocketRequest = { request => request.copy(subprotocol = Some("protocol)) })

Others allow you to manually set the Sec-WebSocket-Protocol header directly. (AHC for instance) HttpClient however throws an exception when trying to add the header.

Are there plans to support subprotocols in a generic way across all backends? Or can I just open a PR adding it to HttpClientAsyncBackend, since that is what I need at the moment?

adamw commented 3 years ago

HttpClient support is done - by handling the headers appropriately.

Would be great to implement this in other backends as well, & add a test :)