Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompressHandler gzip's twice #153

Closed
klingtnet opened this issue Apr 4, 2019 · 6 comments · Fixed by #157
Closed

CompressHandler gzip's twice #153

klingtnet opened this issue Apr 4, 2019 · 6 comments · Fixed by #157

Comments

@klingtnet
Copy link
Contributor

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)
}
@klingtnet
Copy link
Contributor Author

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

@elithrar
Copy link
Contributor

elithrar commented Apr 4, 2019 via email

@klingtnet
Copy link
Contributor Author

I'm on it.

klingtnet pushed a commit to spreadshirt/handlers that referenced this issue Apr 13, 2019
This prevents following handlers from encoding the request again since
we dropped the intention to do this.

Fixes gorilla#153
@klingtnet
Copy link
Contributor Author

Please see PR #157 for a fix.

@stale
Copy link

stale bot commented Jun 12, 2019

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.

@stale stale bot added the stale label Jun 12, 2019
@klingtnet
Copy link
Contributor Author

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

@stale stale bot removed the stale label Jun 13, 2019
elithrar pushed a commit that referenced this issue Jul 23, 2019
* Verify that supported Accept-Encoding header are dropped

* Drop accept-encoding header when supported

This prevents following handlers from encoding the request again since
we dropped the intention to do this.

Fixes #153

* Do not use subtests to be compatible with Go <1.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants