From 17c17b2f8faa7ccf6db843b039f814b77f1ce03e Mon Sep 17 00:00:00 2001 From: Michael Gorven Date: Thu, 4 Dec 2025 14:38:08 -0800 Subject: [PATCH] Fix compressed index pages If `redirect404` is used and index pages are compressed, gcsproxy currently decompresses the object but still sends `Content-Encoding: gzip` resulting in a browser error. Use `ReadCompressed()` to fix this. --- cmd/gcsproxy/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/gcsproxy/main.go b/cmd/gcsproxy/main.go index c71f2ea..fcca5c0 100644 --- a/cmd/gcsproxy/main.go +++ b/cmd/gcsproxy/main.go @@ -145,11 +145,11 @@ func proxy(w http.ResponseWriter, r *http.Request) { u = u + "/" } - obj = client.Bucket(params["bucket"]).Object(u + *indexPage) + obj = client.Bucket(params["bucket"]).Object(u + *indexPage).ReadCompressed(acceptsGzip(r)) attr, err = obj.Attrs(ctx) if err == storage.ErrObjectNotExist { - obj = client.Bucket(params["bucket"]).Object(*indexPage) + obj = client.Bucket(params["bucket"]).Object(*indexPage).ReadCompressed(acceptsGzip(r)) attr, err = obj.Attrs(ctx) } }