Handling HTTP ContentEncoding “deflate”

落爺英雄遲暮 提交于 2019-11-29 13:33:46
Grodriguez

In HTTP/1.1, Content-encoding: deflate actually refers to the DEFLATE compression algorithm, as defined by RFC 1951, wrapped in the zlib data format, as defined by RFC 1950.

However some vendors just implement the DEFLATE algorithm as defined RFC 1951, completely ignoring RFC 1950 (no zlib headers).

Others have been hit by the same issue:

In order to work around this, try to instantiate the InflaterInputStream passing an Inflater that was created with the nowrap parameter set to true:

in = new InflaterInputStream(conn.getInputStream()), new Inflater(true));

Unfortunately, using the InflaterInputStream with an Inflater object did not always produce the correct decompression. I had to detect the headers and tell the Inflater where the offset to the payload was.

http://thushw.blogspot.com/2014/05/decoding-html-pages-with-content.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!