httpd: webpath redirect using status found (302)

301 MovedPermanently is cached by the browser which can
be annoying when it is is on base path like / while one
may reuse the domain (e.g. localhost) for other apps/tests.

Fixes #695

Signed-off-by: Jeremy Clerc <jeremy@clerc.io>
This commit is contained in:
Jeremy Clerc
2022-01-26 20:46:33 +01:00
committed by Nicola Murino
parent d2a4178846
commit 9709aed5e6
3 changed files with 8 additions and 8 deletions

View File

@@ -1649,14 +1649,14 @@ func TestWebAdminRedirect(t *testing.T) {
assert.NoError(t, err)
rr := httptest.NewRecorder()
testServer.Config.Handler.ServeHTTP(rr, req)
assert.Equal(t, http.StatusMovedPermanently, rr.Code, rr.Body.String())
assert.Equal(t, http.StatusFound, rr.Code, rr.Body.String())
assert.Equal(t, webLoginPath, rr.Header().Get("Location"))
req, err = http.NewRequest(http.MethodGet, webBasePath, nil)
assert.NoError(t, err)
rr = httptest.NewRecorder()
testServer.Config.Handler.ServeHTTP(rr, req)
assert.Equal(t, http.StatusMovedPermanently, rr.Code, rr.Body.String())
assert.Equal(t, http.StatusFound, rr.Code, rr.Body.String())
assert.Equal(t, webLoginPath, rr.Header().Get("Location"))
}