From 25fb7ca0d957a736fead342d4ea5f66e79daae14 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 19 Aug 2016 09:45:35 +0100 Subject: [PATCH] Return Location headers on 302s WriteHeader must come AFTER Header().Set() else it does nothing, yay! --- src/github.com/matrix-org/go-neb/realms/github/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/go-neb/realms/github/github.go b/src/github.com/matrix-org/go-neb/realms/github/github.go index ce7522f..604e21b 100644 --- a/src/github.com/matrix-org/go-neb/realms/github/github.go +++ b/src/github.com/matrix-org/go-neb/realms/github/github.go @@ -230,8 +230,8 @@ func (r *GithubRealm) OnReceiveRedirect(w http.ResponseWriter, req *http.Request func (r *GithubRealm) redirectOr(w http.ResponseWriter, code int, msg string, logger *log.Entry, ghSession *GithubSession) { if ghSession.ClientsRedirectURL != "" { - w.WriteHeader(302) w.Header().Set("Location", ghSession.ClientsRedirectURL) + w.WriteHeader(302) // technically don't need a body but *shrug* w.Write([]byte(ghSession.ClientsRedirectURL)) } else {