Explorar el Código

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

pull/298/head
ccase hace 4 años
padre
commit
f92094f219
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: BB367E399EBB2B9D
Se han modificado 1 ficheros con 26 adiciones y 1 borrados
  1. +26
    -1
      server/handlers.go

+ 26
- 1
server/handlers.go Ver fichero

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


Cargando…
Cancelar
Guardar