gzip returning junk data with empty response body
itsjamie opened this issue · comments
Jamie Stackhouse commented
When I exit a call that has gone through the gzip middleware, I see it output junk data into the response body.
Cache-Control → private, max-age=30
Content-Encoding → gzip
Content-Length → 23
Content-Type → application/x-gzip
Date → Mon, 20 Apr 2015 12:23:56 GMT
Expires → Mon, 20 Apr 2015 09:24:26 GMT
Vary → Accept-Encoding
��� n�����
Jamie Stackhouse commented
Wasn't exactly junk data, it was the 404 page not found.
We were using
router := gin.New()
router.Use(gzipMiddleware))
Now, I'm wrapping the http.Handler that Gin returns before-hand to handle gzip.
If we could add a .Before()
to the Gin API to register handlers that should come before it hits the muxer rather than after like .Use()
that would allow people to operate entirely in Gin contexts.
Chris Passas commented
I'm getting the ? n????? also when using gzip.
Could you tell me what I can to do fix this?
Thank you in advance.
r := gin.Default()
r.Use(gzip.Gzip(gzip.DefaultCompression))
r.GET("/docs", getDocs)
s := &http.Server{
Addr: ":8080",
Handler: r,
}
s.SetKeepAlivesEnabled(false)
s.ListenAndServe()