]> source.dussan.org Git - gitea.git/commitdiff
Use Request.URL.RequestURI() for fcgi (#14312) (#14314)
authorKyungmin Bae <williambae1@gmail.com>
Wed, 13 Jan 2021 20:30:46 +0000 (05:30 +0900)
committerGitHub <noreply@github.com>
Wed, 13 Jan 2021 20:30:46 +0000 (20:30 +0000)
custom/conf/app.example.ini
routers/routes/chi.go

index 045b4cfed75b1a8cb3200403ef2715e79353197e..e68727eb84524ed61c443318c6817636fb77f041 100644 (file)
@@ -867,7 +867,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
index 6e609fc2f8b23a70015fb83091370391a8cb2122..16fd6ea9052c5a0b409e8f6d11e20cc6aba141fe 100644 (file)
@@ -86,14 +86,14 @@ func LoggerHandler(level log.Level) func(next http.Handler) http.Handler {
                return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
                        start := time.Now()
 
-                       _ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.RequestURI, req.RemoteAddr)
+                       _ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.URL.RequestURI(), req.RemoteAddr)
 
                        next.ServeHTTP(w, req)
 
                        ww := middleware.NewWrapResponseWriter(w, req.ProtoMajor)
 
                        status := ww.Status()
-                       _ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.RequestURI, log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
+                       _ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.URL.RequestURI(), log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
                })
        }
 }
@@ -107,12 +107,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
                                        return
                                }
 
-                               if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
+                               if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
                                        next.ServeHTTP(w, req)
                                        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) {
@@ -139,12 +139,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
                                return
                        }
 
-                       if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
+                       if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
                                next.ServeHTTP(w, req)
                                return
                        }
 
-                       rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix)
+                       rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
                        rPath = strings.TrimPrefix(rPath, "/")
 
                        fi, err := objStore.Stat(rPath)