Procházet zdrojové kódy

server: Replace string/parse trick for cloning with more efficient option.

pull/298/head
ccase před 4 roky
rodič
revize
f92094f219
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: BB367E399EBB2B9D
1 změnil soubory, kde provedl 26 přidání a 1 odebrání
  1. +26
    -1
      server/handlers.go

+ 26
- 1
server/handlers.go Zobrazit soubor

@@ -544,8 +544,33 @@ func resolveWebAddress(r *http.Request, proxyPath string) string {
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 {
if u == nil {
return nil
}

c := &url.URL{}
*c = *u

if u.User != nil {
c.User = &url.Userinfo{}
*c.User = *u.User
}

return c
}

func getURL(r *http.Request) *url.URL {
u, _ := url.Parse(r.URL.String())
if r == nil || r.URL == nil {
return nil
}

u := cloneURL(r.URL)
if u == nil {
return nil
}

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


Načítá se…
Zrušit
Uložit