diff --git a/routers/web/githttp.go b/routers/web/githttp.go index 794c2944bb..a1e11a4cd7 100644 --- a/routers/web/githttp.go +++ b/routers/web/githttp.go @@ -13,6 +13,8 @@ func addOwnerRepoGitHTTPRouters(m *web.Router) { presetGitService := func(service string) func(ctx *context.Context) { return func(ctx *context.Context) { ctx.SetPathParam("preset-git-service", service) } } + // Some users want to use "web-based git client" to access Gitea's repositories, + // so the CORS handler and OPTIONS method are used. m.Group("/{username}/{reponame}", func() { m.Methods("POST,OPTIONS", "/git-upload-pack", presetGitService("git-upload-pack"), repo.ServiceUploadPack) m.Methods("POST,OPTIONS", "/git-receive-pack", presetGitService("git-receive-pack"), repo.ServiceReceivePack) diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go index 3b7d460625..f1a01145c2 100644 --- a/routers/web/repo/githttp.go +++ b/routers/web/repo/githttp.go @@ -189,7 +189,7 @@ func httpBase(ctx *context.Context) *serviceHandler { } if repoExist { - // Because of special ref "refs/for" .. , need delay write permission check + // Because of special ref "refs/for" (agit) , need delay write permission check if git.DefaultFeatures().SupportProcReceive { accessMode = perm.AccessModeRead } @@ -350,7 +350,7 @@ func setHeaderNoCache(ctx *context.Context) { func setHeaderCacheForever(ctx *context.Context) { now := time.Now().Unix() - expires := now + 31536000 + expires := now + 365*86400 // 365 days ctx.Resp.Header().Set("Date", strconv.FormatInt(now, 10)) ctx.Resp.Header().Set("Expires", strconv.FormatInt(expires, 10)) ctx.Resp.Header().Set("Cache-Control", "public, max-age=31536000")