diff options
author | Linquize <linquize@yahoo.com.hk> | 2015-03-28 22:30:05 +0800 |
---|---|---|
committer | Linquize <linquize@yahoo.com.hk> | 2015-03-28 22:30:05 +0800 |
commit | f26f8d5afa8d84e4cf3fde6c956dcf907d7883b5 (patch) | |
tree | e73ded80d63ff676598505228199a9943bf3d588 /routers | |
parent | 9fb2d49b93022d635147c09bcad7134570979909 (diff) | |
download | gitea-f26f8d5afa8d84e4cf3fde6c956dcf907d7883b5.tar.gz gitea-f26f8d5afa8d84e4cf3fde6c956dcf907d7883b5.zip |
Set Content-Type to text/plain for http status 401
This is because git command line shows the failure reason only if Content-Type is text/plain.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/http.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go index 9165128a36..8395d1c041 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -96,12 +96,12 @@ func Http(ctx *middleware.Context) { // FIXME: middlewares/context.go did basic auth check already, // maybe could use that one. if len(auths) != 2 || auths[0] != "Basic" { - ctx.Handle(401, "no basic auth and digit auth", nil) + ctx.HandleText(401, "no basic auth and digit auth") return } authUsername, authPasswd, err = base.BasicAuthDecode(auths[1]) if err != nil { - ctx.Handle(401, "no basic auth and digit auth", nil) + ctx.HandleText(401, "no basic auth and digit auth") return } @@ -116,7 +116,7 @@ func Http(ctx *middleware.Context) { token, err := models.GetAccessTokenBySha(authUsername) if err != nil { if err == models.ErrAccessTokenNotExist { - ctx.Handle(401, "invalid token", nil) + ctx.HandleText(401, "invalid token") } else { ctx.Handle(500, "GetAccessTokenBySha", err) } @@ -138,23 +138,23 @@ func Http(ctx *middleware.Context) { has, err := models.HasAccess(authUser, repo, tp) if err != nil { - ctx.Handle(401, "no basic auth and digit auth", nil) + ctx.HandleText(401, "no basic auth and digit auth") return } else if !has { if tp == models.ACCESS_MODE_READ { has, err = models.HasAccess(authUser, repo, models.ACCESS_MODE_WRITE) if err != nil || !has { - ctx.Handle(401, "no basic auth and digit auth", nil) + ctx.HandleText(401, "no basic auth and digit auth") return } } else { - ctx.Handle(401, "no basic auth and digit auth", nil) + ctx.HandleText(401, "no basic auth and digit auth") return } } if !isPull && repo.IsMirror { - ctx.Handle(401, "can't push to mirror", nil) + ctx.HandleText(401, "can't push to mirror") return } } |