refactor: headers handling

This commit is contained in:
yusing
2025-05-26 19:57:39 +08:00
parent 216c03c5ff
commit 4a6bed7728
3 changed files with 41 additions and 33 deletions

View File

@@ -271,7 +271,7 @@ func (p *ReverseProxy) handler(rw http.ResponseWriter, req *http.Request) {
return
}
req.Header.Del("Forwarded")
outreq.Header.Del("Forwarded")
httpheaders.RemoveHopByHopHeaders(outreq.Header)
// Issue 21096: tell backend applications that care about trailer support
@@ -312,7 +312,7 @@ func (p *ReverseProxy) handler(rw http.ResponseWriter, req *http.Request) {
}
var reqScheme string
if req.TLS != nil {
if req.TLS != nil || req.Header.Get("X-Forwarded-Proto") == "https" {
reqScheme = "https"
} else {
reqScheme = "http"