Use github.com/klauspost/compress/gzhttp instead of github.com/NYTimes/gziphandler

This commit is contained in:
Lunny Xiao
2024-04-19 13:44:35 +08:00
parent 61457cdf6b
commit 51d57d79ba
4 changed files with 9 additions and 11 deletions
+4 -3
View File
@@ -4,6 +4,7 @@
package web
import (
"compress/gzip"
gocontext "context"
"net/http"
"strings"
@@ -48,9 +49,9 @@ import (
_ "code.gitea.io/gitea/modules/session" // to registers all internal adapters
"gitea.com/go-chi/captcha"
"github.com/NYTimes/gziphandler"
chi_middleware "github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
"github.com/klauspost/compress/gzhttp"
"github.com/prometheus/client_golang/prometheus"
)
@@ -241,11 +242,11 @@ func Routes() *web.Route {
var mid []any
if setting.EnableGzip {
h, err := gziphandler.GzipHandlerWithOpts(gziphandler.MinSize(GzipMinSize))
wrapper, err := gzhttp.NewWrapper(gzhttp.MinSize(GzipMinSize), gzhttp.CompressionLevel(gzip.BestSpeed))
if err != nil {
log.Fatal("GzipHandlerWithOpts failed: %v", err)
}
mid = append(mid, h)
mid = append(mid, wrapper)
}
if setting.Service.EnableCaptcha {