Replace 302 with 303 redirect More appropriate use of HTTP status code
alex wennerberg alex@alexwennerberg.com
Fri, 30 Oct 2020 19:30:06 -0700
1 files changed,
6 insertions(+),
6 deletions(-)
jump to
M
http.go
→
http.go
@@ -131,7 +131,7 @@ log.Println(err)
renderError(w, InternalServerErrorMsg, 500) return } - http.Redirect(w, r, "/my_site", 302) + http.Redirect(w, r, "/my_site", 303) } }@@ -170,7 +170,7 @@ }
defer f.Close() io.Copy(f, bytes.NewReader(dest)) } - http.Redirect(w, r, "/my_site", 302) + http.Redirect(w, r, "/my_site", 303) } // bool whether auth'd, string is auth user@@ -191,7 +191,7 @@ filePath := path.Join(c.FilesDirectory, authUser, fileName)
if r.Method == "POST" { os.Remove(filePath) // suppress error } - http.Redirect(w, r, "/my_site", 302) + http.Redirect(w, r, "/my_site", 303) } func mySiteHandler(w http.ResponseWriter, r *http.Request) {@@ -249,7 +249,7 @@ session, _ := SessionStore.Get(r, "cookie-session")
session.Values["auth_user"] = name session.Values["admin"] = isAdmin session.Save(r, w) - http.Redirect(w, r, "/my_site", 302) + http.Redirect(w, r, "/my_site", 303) } else { data := struct { Error string@@ -269,7 +269,7 @@ func logoutHandler(w http.ResponseWriter, r *http.Request) {
session, _ := SessionStore.Get(r, "cookie-session") session.Options.MaxAge = -1 session.Save(r, w) - http.Redirect(w, r, "/", 302) + http.Redirect(w, r, "/", 303) } const ok = "-0123456789abcdefghijklmnopqrstuvwxyz"@@ -430,7 +430,7 @@ log.Println(err)
renderError(w, InternalServerErrorMsg, 500) return } - http.Redirect(w, r, "/admin", 302) + http.Redirect(w, r, "/admin", 303) } }