Closed mstetson closed 6 years ago
@daaku We just ran into this issue too. We spent two full days trying to figure out why things were failing. Please accept this pull request. It is far too easy for someone else to run into this too.
Though I believe my pull request does fix this specific issue, I ran into several other problems using my fork in production over the year following the pull request. In the end, I wrote something more complex, but I believe more robust. I've been using it in our code for about 15 months now. You may want to take a look: https://bitbucket.org/classroomsystems/gziphandler/
There's also https://github.com/NYTimes/gziphandler. I just added a note to the readme saying don't use this library.
If a wrapped handler adds a Content-Length header to the response (as does http.FileServer), it will not match the gzipped length, confusing the client. This change ensures any Content-Length header is removed, even if the client calls WriteHeader explicitly.