[
https://issues.apache.org/jira/browse/HTTPCLIENT-1699?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16090995#comment-16090995
]
Patrick Doyle commented on HTTPCLIENT-1699:
-------------------------------------------
Still happens for me with 4.5.3.
Backtrace:
{code}
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
~[na:1.8.0_131]
at java.util.zip.InflaterInputStream.read(Unknown Source)
~[na:1.8.0_131]
at java.util.zip.GZIPInputStream.read(Unknown Source) ~[na:1.8.0_131]
at
org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:70)
~[httpclient-4.5.3.jar:4.5.3]
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[na:1.8.0_131]
at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[na:1.8.0_131]
at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[na:1.8.0_131]
at java.io.InputStreamReader.read(Unknown Source) ~[na:1.8.0_131]
at java.io.Reader.read(Unknown Source) ~[na:1.8.0_131]
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2001)
~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980)
~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957)
~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907)
~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:778)
~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:803)
~[commons-io-2.4.jar:2.4]
at org.vena.icecube.server.Main.lambda$33(Main.java:445) ~[classes/:na]
{code}
The offending code is the last line of this:
{code}
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
if (response.getStatusLine().getStatusCode() == 200) {
try {
String body =
IOUtils.toString(response.getEntity().getContent(), "utf8");
{code}
The httpClient object was created this way:
{code}
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
{code}
> Content of response with content-encoding: deflate cannot be read
> -----------------------------------------------------------------
>
> Key: HTTPCLIENT-1699
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1699
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (classic)
> Affects Versions: 4.5.1
> Environment: Windows7,
> java version "1.8.0_66"
> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
> Reporter: Svilena Momova
> Fix For: 4.5.2
>
>
> Hello,
> I'm using httpclient-4.5.1. Yesterday I received http chunked response with
> content-encoding header with value "deflate".
> Trying to read the compressed content from the response I get an exception
> with the following stack trace:
> {noformat}
> java.io.EOFException: Unexpected end of ZLIB input stream
> at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
> at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
> at
> org.apache.http.client.entity.DeflateInputStream.read(DeflateInputStream.java:153)
> at
> org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:73)
> {noformat}
> It seems that when the end of the content is reached, instead of correct
> closing of the stream, this exception happens.
> Can you please confirm the issue and when it could be fixed?
> Thank you!
> Best Regards,
> Svilena Momova
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]