hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Michael.Fankanow...@t-systems.com>
Subject Consuming compressed content throws exception
Date Wed, 25 Apr 2012 12:52:43 GMT
Hi all,

when trying to consume deflate content coded responses I get "java.util.zip.ZipException:
invalid stored block lengths" exception.

server mock looks like:

header is byte array 

Deflater def = new Deflater(Deflater.BEST_COMPRESSION);
contentLength = def.deflate(compressedContent);

// concat header and content
System.arraycopy(header, 0, response, 0, header.length);
System.arraycopy(compressedContent, 0, response, header.length, contentLength);

// sending response to socket
OutputStream outputStream = null;
BufferedOutputStream bos = null;
outputStream = socket.getOutputStream();
bos = new BufferedOutputStream(outputStream);

client side looks like:

response = client.execute(method);
entity = response.getEntity();
DeflateDecompressingEntity dde = new DeflateDecompressingEntity(entity);
         bais = (ByteArrayInputStream) entity.getContent();
  java.util.zip.ZipException: invalid stored block lengths
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
        at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:169)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at org.apache.http.client.entity.DeflateDecompressingEntity.getDecompressingInputStream(DeflateDecompressingEntity.java:104)
        at org.apache.http.client.entity.DecompressingEntity.getContent(DecompressingEntity.java:72)

What could cause this exception?

If I use gzipped content (with appropriate classes) I get a "No GZIP format" exception. When
I decompress content directly after compression I get the right content. I guess there must
be a general problem with my setup.

Kind regards,

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message