From 2eb2d1d7f4526eff86f235667286284457c1585b Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 22 Mar 2017 23:39:59 +0100 Subject: [PATCH] Fixes for redirects and uploads with empty host --- server/handlers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/handlers.go b/server/handlers.go index eef4f76..ce46204 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -360,6 +360,7 @@ func getURL(r *http.Request) *url.URL { if u.Host != "" { } else if host, port, err := net.SplitHostPort(r.Host); err != nil { + u.Host = r.Host } else { if port == "80" && u.Scheme == "http" { u.Host = host @@ -596,7 +597,7 @@ func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc { } else if r.Header.Get("X-Forwarded-Proto") == "https" { } else if r.URL.Scheme == "https" { } else { - u := *r.URL + u := getURL(r) u.Scheme = "https" http.Redirect(w, r, u.String(), http.StatusPermanentRedirect)