From d89155a6eea8f172a50d15109c8b43158a4f54ff Mon Sep 17 00:00:00 2001 From: yusing Date: Mon, 7 Oct 2024 16:44:18 +0800 Subject: [PATCH] idlewatcher fixed idlewatcher incorrect respond haviour, keep url path --- internal/docker/idlewatcher/waker.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/docker/idlewatcher/waker.go b/internal/docker/idlewatcher/waker.go index 0d4d853b..92aa68e3 100644 --- a/internal/docker/idlewatcher/waker.go +++ b/internal/docker/idlewatcher/waker.go @@ -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)) @@ -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 }