-
-
Notifications
You must be signed in to change notification settings - Fork 460
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
feat: Allow custom origin header for Websocket #702
base: master
Are you sure you want to change the base?
Conversation
// Automatically add Origin header for websocket endpoints if there isn't one specified | ||
if endpoint.Type() == EndpointTypeWS { | ||
if _, originHeaderExists := endpoint.Headers[OriginHeader]; !originHeaderExists { | ||
endpoint.Headers[OriginHeader] = Origin | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that adding support for passing the origin header is worth it, I think perhaps we shouldn't add it by default here but instead add a note in the docs mentioning that users may have to specify an Origin
header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TwiN It seems as the code as in this PR ensures that the current behavior, which users might rely on, continues to functions as it has. I'm unsure if ceasing the specify the Origin header will end up being a backwards incompatible change. What is the benefit of no longer specifying the Origin header on any websocket call unless it is explicitly specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kadaan I don't personally have any websocket endpoint handy to test this on; I'm just trying to avoid backward incompatible changes to the best of my ability. Could you investigate this? Once the conflicts are resolved, I wouldn't mind merging this.
Summary
The issue described in #641 (comment) was caused by an hardcoded origin header at
gatus/client/client.go
Line 265 in 1e431c7
bad status
, from https://github.com/golang/net/blob/ab271c317248ea0f18481852f96d12d5eca05cf8/websocket/hybi.go#L440-L445)This PR allows to customize the origin header.
Example
Fixes #641
Checklist
README.md
, if applicable.