Skip to content

Commit

Permalink
golink: set HTTP status after Location header
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
willnorris committed Nov 15, 2023
1 parent 7db43e2 commit 7f89e2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion golink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7f89e2e

Please sign in to comment.