joffrey-bion / krossbow

A Kotlin multiplatform coroutine-based STOMP client over websockets, with built-in conversions.
MIT License
196 stars 14 forks source link

New `supportsCustomHeaders` property in `WebSocketClient` interface #474

Closed joffrey-bion closed 5 months ago

joffrey-bion commented 5 months ago

Some WebSocketClient implementations do not support sending custom headers in the handshake, and this cannot be implemented in Krossbow. Here are some cases where it's just not possible right now:

Calling connect() with a non-empty headers map on these clients currently causes an IllegalArgumentException. It would be nice to allow consumers to check up front whether the client supports custom headers.

Possible implementations:

It would also simplify tests.

joffrey-bion commented 5 months ago

Use different types in generally more appealing, because the API is not "lying" by advertising a headers parameter that is not respected and fails the call.

However, it's not always technically possible to implement different interfaces when the header support of the implementation depends on factors that Krossbow doesn't control. For instance, when wrapping Ktor's web socket, the support depends on the engine, which is not statically known.

We'll have to go the other way: using a property.