From e846b712fc0667c0085cffcc52e4fe9a8fc3ad60 Mon Sep 17 00:00:00 2001 From: Kyungmin Bae Date: Fri, 15 Jan 2021 21:26:45 +0900 Subject: [PATCH] Use Request.URL.RequestURI() for fcgi (#14312) (#14347) Co-authored-by: Lauris BH --- custom/conf/app.example.ini | 2 +- routers/routes/routes.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 529ccea937..f060f13c58 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -850,7 +850,7 @@ MACARON = file ROUTER_LOG_LEVEL = Info ROUTER = console ENABLE_ACCESS_LOG = false -ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}" +ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}" ACCESS = file ; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" LEVEL = Info diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 0e7934a552..bdde8216c4 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -121,11 +121,11 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor return } - if !strings.HasPrefix(req.RequestURI, "/"+prefix) { + if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) { return } - rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix) + rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix) u, err := objStore.URL(rPath, path.Base(rPath)) if err != nil { if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) { @@ -152,11 +152,11 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor return } - if !strings.HasPrefix(req.RequestURI, "/"+prefix) { + if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) { return } - rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix) + rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix) rPath = strings.TrimPrefix(rPath, "/") //If we have matched and access to release or issue fr, err := objStore.Open(rPath)