Created
June 2, 2013 23:14
-
-
Save johnboxall/5695301 to your computer and use it in GitHub Desktop.
Go's default redirect behaviour seems to merge slashes in HTTP redirects. How can you override this behaviour?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"net/http" | |
"net/http/httptest" | |
) | |
func TestMergeSlashes(t *testing.T) { | |
req, _ := http.NewRequest("GET", "http://foo.com/", nil) | |
resp := httptest.NewRecorder() | |
http.Redirect(resp, req, "/http://bar.com/", 302) | |
if g, e := resp.Header().Get("Location"), "/http://bar.com/"; g != e { | |
t.Errorf("Location header was %q; want %q", g, e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment