Skip to content

Commit

Permalink
Merge pull request dutchcoders#339 from dutchcoders/PR-298
Browse files Browse the repository at this point in the history
clone url
  • Loading branch information
aspacca authored Jan 6, 2021
2 parents fe9e699 + d554eb8 commit be6dea2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,22 @@ func resolveWebAddress(r *http.Request, proxyPath string, proxyPort string) stri
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 {
u, _ := url.Parse(r.URL.String())
u := cloneURL(r.URL)

if r.TLS != nil {
u.Scheme = "https"
Expand Down

0 comments on commit be6dea2

Please sign in to comment.