From e834388d2b4ad74c94abbc0c51868b1cbfb6f11f Mon Sep 17 00:00:00 2001 From: Will Norris Date: Tue, 14 Nov 2023 21:26:07 -0800 Subject: [PATCH] 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 --- golink.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golink.go b/golink.go index 83cde7e..560b232 100644 --- a/golink.go +++ b/golink.go @@ -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.