-
Notifications
You must be signed in to change notification settings - Fork 5
fix: handler HEAD calls in sse routes #96
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
base: main
Are you sure you want to change the base?
Conversation
dido18
left a comment
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.
I suggest using a reusable middleware
func headMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "HEAD" {
w.WriteHeader(http.StatusOK)
return
}
next.ServeHTTP(w, r)
})
}
usage
mux.Handle("GET /v1/apps/events", headMiddleware(handlers.HandlerAppStatus(dockerClient, idProvider, cfg)))
I was thinking about that but I was also concern by the fact that I think the HEAD request should do the same parameter checks we are doing in the GET request and not always return 200 OK. For instance, I would expect that Will return an error because tail should be a number. In that sense the HEAD request is like a pre-fligth of the GET request. Anyway i didn't read explicit mansion of parameter validation in the HEAD semantics document here. They only say that the HEAD method should behave like the GET method without the body, which is a little bit left to the interpretation. |
|
But why is the FE sending the HEAD request?
ok, it is strange that the FE is sending a HEAD to the SSE endpoint. What clients is the FE using to call the SSE endpoint? |
Motivation
On SSE handlers, we need to make sure that we early return in HEAD calls, otherwise we remain attacked forever.
Change description
Additional Notes
Reviewer checklist
main.