clone url

This commit is contained in:
Andrea Spacca 2021-01-06 13:33:46 +01:00
parent d3b6fd5e90
commit d554eb8e2d

View file

@ -556,8 +556,22 @@ func resolveWebAddress(r *http.Request, proxyPath string, proxyPort string) stri
return webAddress return webAddress
} }
// Similar to the logic found here:
// https://github.com/golang/go/blob/release-branch.go1.14/src/net/http/clone.go#L22-L33
func cloneURL(u *url.URL) *url.URL {
c := &url.URL{}
*c = *u
if u.User != nil {
c.User = &url.Userinfo{}
*c.User = *u.User
}
return c
}
func getURL(r *http.Request, proxyPort string) *url.URL { func getURL(r *http.Request, proxyPort string) *url.URL {
u, _ := url.Parse(r.URL.String()) u := cloneURL(r.URL)
if r.TLS != nil { if r.TLS != nil {
u.Scheme = "https" u.Scheme = "https"