-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow sending custom headers in more frames #507
Comments
Hello! Thanks for sharing your use case. I intend to do some rework around headers in general at some point, and this is good input. Indeed the spec technically only allows user-defined headers in Sending a raw |
This would have been an ideal way to deal with custom headers, but not only it deviates the library from specifications, but also adds extra code to be tested.
I understand, but this adds flexibility to whoever wants to use the library for custom needs. The current problem with making StompFrame.Receipt(StompReceiptHeaders(StompHeaders())) // StompHeaders is interface
StompFrame.Receipt(StompReceiptHeaders(SimpleStompHeaders())) // SimpleStompHeaders is internal With this the first option starts to look better. |
Yes, I enforced the spec constraints in multiple places :) That's why I will need to change things around the headers to make this happen. But anyway headers need to change. I don't like the current mutability. It was done as a premature performance optimization, but it has a cost in correctness. I'll keep this issue in mind when I do rework this part. And also I'll see what's best for |
Meanwhile, is there a workaround for sending custom headers without writing my own WebsocketClient? |
I tried to look for one, but I don't think there is, unfortunately. Sorry |
I tried making changes in this PR the header constructors. Can you please let me know if anything more is needed regarding code or unit tests? |
It turns out the spec actually opens the door for anything in this sentence:
So I decided to allow custom headers without opt-in in the new headers design. |
Problem / use case
I ran into a use case where I would like to send custom headers in an ACK frame. This might sound unusual, given the specification only mentions the headers
id
andtransaction.
However, I'm porting a JS implementation, and the JS client allows arbitrary headers. This might be because of loose typing from JS/TS, but sending headers works.Feature (solution)
This is not a standard requirement, so if the library allows sending raw STOMP frames from the session, it will be more flexible.
One solution can be adding a
rawFrame(frame: StompFrame)
in theStompSession
interface. There is already such implementation, but it's a private method.Current alternatives
I haven't found any workarounds yet. If there is one, I would like to go with it instead of requesting library changes.
The text was updated successfully, but these errors were encountered: