nytimes / gziphandler

Go middleware to gzip HTTP responses
https://godoc.org/github.com/NYTimes/gziphandler
Apache License 2.0
868 stars 129 forks source link

Fix Flush breaks response if called while buffering #60

Closed tmthrgd closed 6 years ago

tmthrgd commented 6 years ago

This fixes the bug I noted in https://github.com/NYTimes/gziphandler/pull/58#issuecomment-343036704. In doing so, it reverts 0f67f3f, which was #58, and commits a different fix for that issue.

Where #58 juggled calling WriteHeader within Flush, this pull request simply makes Flush a no-op while the response is buffering, i.e. until it reaches the minimum size.

In reverting 0f67f3f, it has the side-effect of reducing the size of the per-request GzipResponseWriter struct from 104 bytes to 96 bytes.

tmthrgd commented 6 years ago

Ping @jprobinson, any chance this could be reviewed/merged soon? (Sorry for the noise).

jprobinson commented 6 years ago

🍕 thanks!

...and sorry for the wait!