Skip to content

Commit 27ca368

Browse files
committed
Add logging enhancements and remove sensitive headers in RedirectHandler***
***Refactor TranslateStatusCode function in status package
1 parent dc2db1e commit 27ca368

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

redirecthandler/redirecthandler.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,22 @@ func (r *RedirectHandler) checkRedirect(req *http.Request, via []*http.Request)
8888
r.Logger.Info("Changed request method to GET for 303 See Other response")
8989
}
9090

91+
// Logging enhancements
92+
r.Logger.Info("Redirecting request",
93+
zap.String("originalURL", req.URL.String()),
94+
zap.String("newURL", newReqURL.String()),
95+
zap.String("method", req.Method),
96+
zap.Int("redirectCount", len(via)),
97+
)
98+
99+
// Log removed sensitive headers
100+
for _, header := range r.SensitiveHeaders {
101+
r.Logger.Info("Removed sensitive header due to domain change",
102+
zap.String("header", header),
103+
)
104+
}
105+
91106
req.URL = newReqURL
92-
r.Logger.Info("Redirecting request", zap.String("newURL", newReqURL.String()))
93107
return nil
94108
}
95109

status/status.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"net/http"
88
)
99

10-
// TranslateStatusCode provides a human-readable message for HTTP status codes.
1110
// TranslateStatusCode provides a human-readable message for HTTP status codes.
1211
func TranslateStatusCode(resp *http.Response) string {
1312

0 commit comments

Comments
 (0)