We only set it when we know the whole file will be sent because no Range header was on the request. Otherwise we defer to the Range mechanics of the Go Standard library.
The rules are that Content-Length can be set with Content-Encoding but not with Transfer-Encoding.
The Go Standard library does not set Content-Length when Content-Encoding is set as a precautionary measure.
We only set it when we know the whole file will be sent because no Range header was on the request. Otherwise we defer to the Range mechanics of the Go Standard library.
The rules are that Content-Length can be set with Content-Encoding but not with Transfer-Encoding.
The Go Standard library does not set Content-Length when Content-Encoding is set as a precautionary measure.
You can see as an example that Caddy does it.