Open mike10004 opened 6 years ago
If you want to contribute this yourself, I'll let you know when to start. Currently we're in the middle of a very long freeze and I might find myself having to code most of 3.0.0 again and from scratch.
Sure, let me know whenever.
The server automatically gzips outgoing response data streams if the response content type is text and the client will accept it. If the response data is already encoded, this results in the server encoding the data again.
This behavior should be avoided because it is unlikely that there would be any benefit to gzipping a data stream already compressed with gzip or any other compression method.
Expected behavior: a response containing a
Content-Encoding
header with a value other thanidentity
should be served without gzipping the content.Actual behavior: The response content is always gzipped if the Content-Type is text/* (and the
gzipUsage
setting isDEFAULT
orALWAYS
).I encountered this in org.nanohttpd:nanohttpd:2.3.1, but the issue exists in the latest version too, as far as I can tell from examining the current code at Response.java.
The resolution I recommend is to modify the
useGzipWhenAccepted
method to return false if the response contains a Content-Encoding header whose value is anything other thanidentity
, regardless of what thegzipUsage
setting is. I'd be glad to submit a pull request if this resolution is acceptable.