From 4645d8df16e2f8cdb074571d006d5db159bdb5db Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 1 Apr 2020 15:03:05 -0700 Subject: [PATCH] Don't consider x-forwarded-port for the value of HTTP HOST --- pkg/schemaserver/urlbuilder/base.go | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/pkg/schemaserver/urlbuilder/base.go b/pkg/schemaserver/urlbuilder/base.go index 48c12d78..bffcefee 100644 --- a/pkg/schemaserver/urlbuilder/base.go +++ b/pkg/schemaserver/urlbuilder/base.go @@ -3,7 +3,6 @@ package urlbuilder import ( "bytes" "fmt" - "net" "net/http" "net/url" "strings" @@ -22,29 +21,11 @@ func GetHost(r *http.Request, scheme string) string { } host = strings.Split(r.Header.Get(ForwardedHostHeader), ",")[0] - if host == "" { - host = r.Host - } - - port := r.Header.Get(ForwardedPortHeader) - if port == "" { + if host != "" { return host } - if port == "80" && scheme == "http" { - return host - } - - if port == "443" && scheme == "http" { - return host - } - - hostname, _, err := net.SplitHostPort(host) - if err != nil { - hostname = host - } - - return strings.Join([]string{hostname, port}, ":") + return r.Host } func GetScheme(r *http.Request) string {