1
0
Fork 0

Redirection status codes for methods different than GET

This commit is contained in:
Radoslaw Wesolowski 2019-01-07 17:56:04 +01:00 committed by Traefiker Bot
parent 099bbb8be7
commit d7bd69714d
3 changed files with 44 additions and 7 deletions

View file

@ -103,8 +103,15 @@ func (m *moveHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Location", m.location.String())
status := http.StatusFound
if req.Method != http.MethodGet {
status = http.StatusTemporaryRedirect
}
if m.permanent {
status = http.StatusMovedPermanently
if req.Method != http.MethodGet {
status = http.StatusPermanentRedirect
}
}
rw.WriteHeader(status)
_, err := rw.Write([]byte(http.StatusText(status)))