Skip to content

Commit

Permalink
idlewatcher fixed idlewatcher incorrect respond haviour, keep url path
Browse files Browse the repository at this point in the history
  • Loading branch information
yusing committed Oct 7, 2024
1 parent 921ce23 commit d89155a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/docker/idlewatcher/waker.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func (w *Waker) wake(next http.HandlerFunc, rw http.ResponseWriter, r *http.Requ
ctx, cancel := context.WithTimeout(r.Context(), w.WakeTimeout)
defer cancel()

if r.Header.Get(headerCheckRedirect) == "" {
isCheckRedirect := r.Header.Get(headerCheckRedirect) != ""
if !isCheckRedirect {
// Send a loading response to the client
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
rw.Write(w.makeRespBody("%s waking up...", w.ContainerName))
Expand All @@ -63,7 +64,11 @@ func (w *Waker) wake(next http.HandlerFunc, rw http.ResponseWriter, r *http.Requ

// maybe another request came in while we were waiting for the wake
if w.ready.Load() {
next(rw, r)
if isCheckRedirect {
rw.WriteHeader(http.StatusOK)
} else {
next(rw, r)
}
return
}

Expand Down

0 comments on commit d89155a

Please sign in to comment.