Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: ServeContent doesn't set Content-Length when Content-Encoding is set #19420
What version of Go are you using (
referenced this issue
Mar 6, 2017
The Content-Length is supposed to be set to the compressed size, per http://stackoverflow.com/a/3819303/329700, I believe. It's probably better to omit it than to send an incorrect value.
I think the problem in this case is that the
It's never necessary to set Content-Length. If Caddy wants to set its own headers before ServeContent, then it can also set Content-Length. ServeContent is being conservative here and not interfering if the caller is trying to do its own thing.
I'm going to close this for now, but feel free to file a bug again Caddy, or @mholt can argue why ServeContent is doing the wrong thing.