Hi,
TL;DR: Leave Accept-Encoding and Content-Encoding handling to Cronet unless you have a very strong reason not to do so. Expect breakages if you don't.
Detailed answer:
To answer your question directly, no, there's no easy way to prevent Cronet from adding gzip as an accepted encoding and decoding gzipped response bodies.
On the way out, Cronet takes full ownership of the Accept-Encoding header and prohibits users from customizing the headers. The reason is covered in
https://crbug.com/581399. The way to set the headers implicitly is to enable a particular encoding on the Cronet engine (e.g. enableBrotli()), which also sets up the decompression path. Users of Cronet should always receive the decoded stream and shouldn't worry about transport level compression or encoding. Gzip in Cronet is a non-configurable option, enabled by default.
As a result of the above, Cronet doesn't expect encodings it doesn't know about in the response (or that are disabled), so the below behavior isn't part of the public Cronet contract. Anyway, here's what happens with an ill-behaved server sending undesired data.
- if Cronet sees an encoding it doesn't know how to handle at all (e.g. "my-custom-encoding") it doesn't attempt to decode the stream and simply passes it along.
- if Cronet sees an encoding it knows how to handle and support for it is enabled, it decodes the stream. Notably, it doesn't strip the headers - Content-Encoding and Content-Length, if set, will refer to the encoded stream (see the bug above for more details).
- if Cronet sees an encoding it knows how to handle and support for it is disabled, Cronet fails with a
Content Decoding Failed error.
Hope this helps, please feel free to follow up with further questions.
Dan