golink: set HTTP status after Location header

I didn't think the order mattered (as long as none of the response body
had been written), but I guess I was wrong. Currently, it's returning
the 302 status, but no Location header. And tests, at least some of
which should be passing through this full code path, are passing. I'll
look into adding better testing later, but for now this fixes the
immediate issue.

Updates #91

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-11-14 21:42:41 -08:00
committed by Will Norris
parent 7db43e2d37
commit 7f89e2e42c
+1 -1
View File
@@ -425,8 +425,8 @@ func serveGo(w http.ResponseWriter, r *http.Request) {
// http.Redirect always cleans the redirect URL, which we don't always want.
// Instead, manually set status and Location header.
w.WriteHeader(http.StatusFound)
w.Header().Set("Location", target.String())
w.WriteHeader(http.StatusFound)
}
// acceptHTML returns whether the request can accept a text/html response.