From d400456c9c621113a38c66b78f9169766c55abb6 Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Thu, 15 Aug 2024 05:48:35 +0900 Subject: [PATCH] use BestCompression in GzipEncoding This probably won't matter for modern browsers as they can use brotli/zstd, but there are still many curl installations that only support gzip (the same is also true for the default HTTP client in Go). --- server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index d735c5e..8f0153a 100644 --- a/server.go +++ b/server.go @@ -474,7 +474,10 @@ func GzipEncoding() Encoding { }, Encoder: func(r io.Reader) ([]byte, error) { res := bytes.NewBuffer(nil) - w := gzip.NewWriter(res) + w, err := gzip.NewWriterLevel(res, gzip.BestCompression) + if err != nil { + return nil, err + } if _, err := io.Copy(w, r); err != nil { return nil, err