Skip to content
Snippets Groups Projects
Commit 5e6d8bea authored by Will McCutchen's avatar Will McCutchen
Browse files

Properly handle status 308 Permanent Redirect (fixes #46)

parent 3fb53d7c
No related branches found
No related tags found
No related merge requests found
...@@ -172,12 +172,26 @@ func (h *HTTPBin) Status(w http.ResponseWriter, r *http.Request) { ...@@ -172,12 +172,26 @@ func (h *HTTPBin) Status(w http.ResponseWriter, r *http.Request) {
"accept": acceptedMediaTypes, "accept": acceptedMediaTypes,
}) })
http308body := []byte(`<!doctype html>
<head>
<title>Permanent Redirect</title>
</head>
<body>Permanently redirected to <a href="/image/jpeg">/image/jpeg</a>
</body>
</html>`)
specialCases := map[int]*statusCase{ specialCases := map[int]*statusCase{
301: redirectHeaders, 301: redirectHeaders,
302: redirectHeaders, 302: redirectHeaders,
303: redirectHeaders, 303: redirectHeaders,
305: redirectHeaders, 305: redirectHeaders,
307: redirectHeaders, 307: redirectHeaders,
308: {
body: http308body,
headers: map[string]string{
"Location": "/image/jpeg",
},
},
401: { 401: {
headers: map[string]string{ headers: map[string]string{
"WWW-Authenticate": `Basic realm="Fake Realm"`, "WWW-Authenticate": `Basic realm="Fake Realm"`,
......
...@@ -710,6 +710,13 @@ func TestStatus(t *testing.T) { ...@@ -710,6 +710,13 @@ func TestStatus(t *testing.T) {
{200, nil, ""}, {200, nil, ""},
{301, redirectHeaders, ""}, {301, redirectHeaders, ""},
{302, redirectHeaders, ""}, {302, redirectHeaders, ""},
{308, map[string]string{"Location": "/image/jpeg"}, `<!doctype html>
<head>
<title>Permanent Redirect</title>
</head>
<body>Permanently redirected to <a href="/image/jpeg">/image/jpeg</a>
</body>
</html>`},
{401, unauthorizedHeaders, ""}, {401, unauthorizedHeaders, ""},
{418, nil, "I'm a teapot!"}, {418, nil, "I'm a teapot!"},
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment