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

Allow body to be empty #16

Closed Thomasdezeeuw closed 8 years ago

Thomasdezeeuw commented 8 years ago

This change allows the body to be completely empty, that means without gzip headers. This a requirement with status codes that do not allow for a body, for example 204 No Content.

It also changes to a lazily initialise method for the gzip writer.

Fixes #5.

Thomasdezeeuw commented 8 years ago

I've updated the code to run on < Go 1.7.

Thomasdezeeuw commented 8 years ago

Ping.

jprobinson commented 8 years ago

Sorry for the delay, we had a change of repo ownership in the past week and this fell through the gaps.

This looks good to me. Thanks for contributing!

adammck commented 8 years ago

Thanks for adopting this one, @jprobinson! (And sorry, @Thomasdezeeuw, for leaving you hanging.)

jprobinson commented 8 years ago

Just to add an update...we found this introduced a bug for any handler calling WriteHeader before writing the actual body to the response.

We ended up altering the library in #19 to still allow empty responses, but only for 204 and 304.

Thomasdezeeuw commented 8 years ago

Thanks.