gorilla/handlers

CompressHandler gzip's twice

klingtnet opened this issue · 6 comments

The CompressHandler of [gorilla/handlers][1] gzips responses twice if they're already gzipped, i.e. it ignores the Content-Encoding header.

Here's a minimal working example:

package main

import (
	"fmt"
	"net/http"

	"github.com/gorilla/handlers"
	"github.com/gorilla/mux"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
	r := mux.NewRouter()

	r.Handle("/", promhttp.Handler())
	r.Use(handlers.CompressHandler)

	fmt.Println("Listening on :9999")
	http.ListenAndServe(":9999", r)
}

A repository with the minimal working example and instructions on how to reproduce it can be found here: https://github.com/spreadshirt/gorilla-handlers-double-gzip-bug

I'm on it.

Please see PR #157 for a fix.

stale commented

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

This message is to keep the issue from being closed automatically.