Skip to content

Commit

Permalink
fix req headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Aug 3, 2022
1 parent 3e23fe5 commit 3ef6387
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func New(ApiManager types.ApiManager, roomConfig *config.Room, config *config.Se

for k, vv := range r.Header {
for _, v := range vv {
r.Header.Add(k, v)
req.Header.Add(k, v)
}
}

Expand All @@ -88,31 +88,31 @@ func New(ApiManager types.ApiManager, roomConfig *config.Room, config *config.Se
//

if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil {
r.Header.Add("X-Forwarded-For", clientIP)
req.Header.Add("X-Forwarded-For", clientIP)
}

if r.Method != "" {
r.Header.Add("X-Forwarded-Method", r.Method)
req.Header.Add("X-Forwarded-Method", r.Method)
} else {
r.Header.Del("X-Forwarded-Method")
req.Header.Del("X-Forwarded-Method")
}

if r.TLS != nil {
r.Header.Add("X-Forwarded-Proto", "https")
req.Header.Add("X-Forwarded-Proto", "https")
} else {
r.Header.Add("X-Forwarded-Proto", "http")
req.Header.Add("X-Forwarded-Proto", "http")
}

if r.Host != "" {
r.Header.Add("X-Forwarded-Host", r.Host)
req.Header.Add("X-Forwarded-Host", r.Host)
} else {
r.Header.Del("X-Forwarded-Host")
req.Header.Del("X-Forwarded-Host")
}

if r.URL.RequestURI() != "" {
r.Header.Add("X-Forwarded-Uri", r.URL.RequestURI())
req.Header.Add("X-Forwarded-Uri", r.URL.RequestURI())
} else {
r.Header.Del("X-Forwarded-Uri")
req.Header.Del("X-Forwarded-Uri")
}

client := &http.Client{
Expand Down

0 comments on commit 3ef6387

Please sign in to comment.