From 0b999e6bbeda97ff393fd5a615c64ee0705f92fe Mon Sep 17 00:00:00 2001 From: Abhishek Govindarasu Date: Fri, 27 Sep 2024 21:10:53 -0700 Subject: [PATCH] filter proxy headers --- hook/handlers/index.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hook/handlers/index.go b/hook/handlers/index.go index 643d35d..51cf321 100644 --- a/hook/handlers/index.go +++ b/hook/handlers/index.go @@ -1,7 +1,6 @@ package handlers import ( - "fmt" "io" "net/http" "strings" @@ -29,15 +28,10 @@ func Index(w http.ResponseWriter, r *http.Request) { body = []byte{} } + headers := http.Header{} for key := range response.Headers { - if strings.HasPrefix(key, "Cf-") || key == "Cdn-Loop" || key == "X-Real-IP" || key == "X-Forwarded-For" || key == "X-Forwarded-Proto" { - r.Header.Del(key) - } - } - - for key, values := range r.Header { - for _, value := range values { - fmt.Println("Header:", key, value) + if !(strings.HasPrefix(key, "Cf-") || key == "Cdn-Loop" || key == "X-Real-IP" || key == "X-Forwarded-For" || key == "X-Forwarded-Proto") { + headers.Add(key, response.Headers[key]) } } @@ -47,7 +41,7 @@ func Index(w http.ResponseWriter, r *http.Request) { Path: r.URL.Path, Sender: r.Header.Get("X-Real-IP"), Query: r.URL.Query(), - Headers: r.Header, + Headers: headers, Body: string(body), Time: time.Now(), })