瀏覽代碼

clone url

tags/v1.2.0
Andrea Spacca 3 年之前
父節點
當前提交
d554eb8e2d
共有 1 個檔案被更改,包括 15 行新增1 行删除
  1. +15
    -1
      server/handlers.go

+ 15
- 1
server/handlers.go 查看文件

@@ -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"


Loading…
取消
儲存