echo
echo copied to clipboard
Bugs fixed in Gzip middleware
-
The Accept-Encoding header parser is more precise. Previously it had been a simple sub-string match, not aware of the possible header grammar.
-
Downstream middleware or handlers will not gzip the response twice now. This makes the middleware easier to use with packages such as Prometheus (which also implements gzipping).
-
Vary header is handled more cleanly. It is not sent unless it is needed. It is now removed from 204 or other empty responses. Although this was not strictly wrong, it was unnecessary and wasteful.
Any plans to continue working on this PR @rickb777?
@lammel I see most of these changes applied to master currently except the removeOneHeaderValue
part.
I can continue if there is anything that needs to be done here or otherwise we can close this?
Seems like all changes landed on master
already. Only one topic remains that was handled with this PR: Shall the gzip ContentEncoding header be set if the response is empty (res.Size == 0)?
According to RFC 7231:
A sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message
Although no clear indication is given what should be done if no payload is sent I think this implies we should not add the header if no payload has been written to the response. We might do that small fix on master and close this, as this PR seems rather stale
Closing this PR in favor of #2355. Thanks @rickb777 for getting this started.