From f31a05399557c14a12992d1faa86ba86c09cc734 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sun, 6 Dec 2015 18:26:56 +0000 Subject: [PATCH] Add a host and scheme to Location headers in redirects Our apache reverse-proxy can't correctly rewrite relative Location headers, so add the Host from the request into the Location. --- scripts/speculator/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/speculator/main.go b/scripts/speculator/main.go index 2e6b48b3..e11e15b5 100644 --- a/scripts/speculator/main.go +++ b/scripts/speculator/main.go @@ -387,8 +387,12 @@ func (s *server) serveSpec(w http.ResponseWriter, req *http.Request) { w.Write([]byte("Not found")) } -func (s *server) redirectTo(w http.ResponseWriter, _ *http.Request, path string) { - w.Header().Set("Location", path) +func (s *server) redirectTo(w http.ResponseWriter, req *http.Request, path string) { + u := *req.URL + u.Scheme = "http" + u.Host = req.Host + u.Path = path + w.Header().Set("Location", u.String()) w.WriteHeader(302) }