If we don't set (or at least clear) the header in that case, we'll pass through the Content-Length of the upstream's response, which can lead to us serving an incomplete response.
In particular, this happens when Rails is serving a gzipped asset via X-Sendfile, which it does using Content-Encoding: gzip and Content-Length: 0.
In most cases,
http.ServeFile
will set this for us. However, it will not set it if the response also has aContent-Encoding
(see https://github.com/golang/go/commit/fdc21f3eafe94490e55e0bf018490b3aa9ba2383).If we don't set (or at least clear) the header in that case, we'll pass through the
Content-Length
of the upstream's response, which can lead to us serving an incomplete response.In particular, this happens when Rails is serving a gzipped asset via
X-Sendfile
, which it does usingContent-Encoding: gzip
andContent-Length: 0
.Fixes #8.