mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Replace #27894 Backport #30592 Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -48,9 +48,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" | ||||
| ) | ||||
|  | ||||
| @@ -244,11 +244,13 @@ func Routes() *web.Route { | ||||
| 	var mid []any | ||||
|  | ||||
| 	if setting.EnableGzip { | ||||
| 		h, err := gziphandler.GzipHandlerWithOpts(gziphandler.MinSize(GzipMinSize)) | ||||
| 		// random jitter is recommended by: https://pkg.go.dev/github.com/klauspost/compress/gzhttp#readme-breach-mitigation | ||||
| 		// compression level 6 is the gzip default and a good general tradeoff between speed, CPU usage, and compression | ||||
| 		wrapper, err := gzhttp.NewWrapper(gzhttp.RandomJitter(32, 0, false), gzhttp.MinSize(GzipMinSize), gzhttp.CompressionLevel(6)) | ||||
| 		if err != nil { | ||||
| 			log.Fatal("GzipHandlerWithOpts failed: %v", err) | ||||
| 			log.Fatal("gzhttp.NewWrapper failed: %v", err) | ||||
| 		} | ||||
| 		mid = append(mid, h) | ||||
| 		mid = append(mid, wrapper) | ||||
| 	} | ||||
|  | ||||
| 	if setting.Service.EnableCaptcha { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user