mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Update HTTP status codes to modern codes (#18063)
* 2xx/3xx/4xx/5xx -> http.Status... * http.StatusFound -> http.StatusTemporaryRedirect * http.StatusMovedPermanently -> http.StatusPermanentRedirect
This commit is contained in:
@@ -214,7 +214,7 @@ func (ctx *APIContext) RequireCSRF() {
|
||||
if len(headerToken) > 0 || len(formValueToken) > 0 {
|
||||
Validate(ctx.Context, ctx.csrf)
|
||||
} else {
|
||||
ctx.Context.Error(401, "Missing CSRF token.")
|
||||
ctx.Context.Error(http.StatusUnauthorized, "Missing CSRF token.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ func (ctx *APIContext) CheckForOTP() {
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
ctx.Context.Error(401)
|
||||
ctx.Context.Error(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@@ -139,7 +139,7 @@ func RedirectToUser(ctx *Context, userName string, redirectUserID int64) {
|
||||
if ctx.Req.URL.RawQuery != "" {
|
||||
redirectPath += "?" + ctx.Req.URL.RawQuery
|
||||
}
|
||||
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath))
|
||||
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
// HasAPIError returns true if error occurs in form validation.
|
||||
@@ -215,7 +215,7 @@ func (ctx *Context) HTML(status int, name base.TplName) {
|
||||
// RenderToString renders the template content to a string
|
||||
func (ctx *Context) RenderToString(name base.TplName, data map[string]interface{}) (string, error) {
|
||||
var buf strings.Builder
|
||||
err := ctx.Render.HTML(&buf, 200, string(name), data)
|
||||
err := ctx.Render.HTML(&buf, http.StatusOK, string(name), data)
|
||||
return buf.String(), err
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ func (ctx *Context) JSON(status int, content interface{}) {
|
||||
|
||||
// Redirect redirects the request
|
||||
func (ctx *Context) Redirect(location string, status ...int) {
|
||||
code := http.StatusFound
|
||||
code := http.StatusSeeOther
|
||||
if len(status) == 1 {
|
||||
code = status[0]
|
||||
}
|
||||
|
@@ -335,7 +335,7 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
|
||||
if ctx.Req.URL.RawQuery != "" {
|
||||
redirectPath += "?" + ctx.Req.URL.RawQuery
|
||||
}
|
||||
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath))
|
||||
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
||||
|
Reference in New Issue
Block a user