Closed insticore closed 4 years ago
Hi @insticore
Could you tell me what Content-Encoding
the server uses? The decoder enables 'nowrap' only for gzip
as it has it's own wrapping method which is handled by the decoder. deflate
however is expected to be zlib-wrapped so the nowrap
option is not used. I'm guessing you're hit by something like this where the server sends raw zlib bytes without the zlib-wrapping. Could you confirm that?
If that's the case maybe it's better for DeflateDecoder
to auto-detect the zlib wrapper itself instead of letting the user choose between wrap and nowrap.
Hi @mizosoft
The Content-Encoding
is definitely deflate
, I tested body decoding with such implementation
IOUtils.toString(new InflaterInputStream(bodyInputSteam, new Inflater(true)), StandardCharsets.UTF_8)
It works with nowrap
option, but does not without it.
So when I tried to switch to MoreBodyHandlers
it also failed.
It is the case then that the server sends a stream of raw zlib bytes for deflate
. The best fix to this is to make DeflateDecoder
auto-detect such streams and handle both wrapped and unwrapped cases. I'll make the necessary changes soon. Thanks for reporting!
I use MoreBodyHandlers.decoding(BodyHandlers.ofString()), but it fails because 'nowrap' is not enabled for inflating. Could you please explain how to use the decoder with this option?