Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 870D711523 for ; Fri, 5 Sep 2014 07:16:26 +0000 (UTC) Received: (qmail 59303 invoked by uid 500); 5 Sep 2014 07:16:26 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 59264 invoked by uid 500); 5 Sep 2014 07:16:26 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 59253 invoked by uid 99); 5 Sep 2014 07:16:26 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Sep 2014 07:16:26 +0000 Date: Fri, 5 Sep 2014 07:16:26 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (HTTPCLIENT-1550) "deflate" encoding issue : java.util.zip.ZipException: invalid stored block lengths MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oleg Kalnichevski resolved HTTPCLIENT-1550. ------------------------------------------- Resolution: Invalid > "deflate" encoding issue : java.util.zip.ZipException: invalid stored block lengths > ----------------------------------------------------------------------------------- > > Key: HTTPCLIENT-1550 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1550 > Project: HttpComponents HttpClient > Issue Type: Bug > Affects Versions: 4.3.5 > Environment: Windows > Reporter: Guillaume Serre > Priority: Minor > > When trying to GET any nzb files from http://nzbindex.nl with a httpclient request, a ZipException is raised. > {code:title=JunitTestFailing.java} > @Test > public void testDeflateIssueFailing() throws ClientProtocolException, IOException { > HttpGet httpget = new HttpGet("http://nzbindex.nl/download/72441827/BackTrack5R3.Gnome.iSO.32bit-LiNUX-0171-bt5r2gis32.par2.nzb"); > HttpClient client = HttpClientBuilder.create().build(); > HttpResponse response = client.execute(httpget); > HttpEntity entity = response.getEntity(); > byte[] data = EntityUtils.toByteArray( entity ); > Assert.assertEquals( data.length, 423548 ); > } > {code} > The complete stack trace I get is this: > {code} > java.util.zip.ZipException: invalid stored block lengths > at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) > at java.io.FilterInputStream.read(FilterInputStream.java:107) > at org.apache.http.client.entity.DeflateInputStream.read(DeflateInputStream.java:144) > at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:68) > at org.apache.http.util.EntityUtils.toByteArray(EntityUtils.java:136) > at hclient.HTTPClientTest.testDeflateIssueFailing(HTTPClientTest.java:39) > {code} > A workaround I found is to set the Accept-Encoding header to only accept gzip, as follows: > {code:title=JunitTestWorking.java} > > @Test > public void testDeflateIssueWorking() throws ClientProtocolException, IOException { > HttpGet httpget = new HttpGet("http://nzbindex.nl/download/72441827/BackTrack5R3.Gnome.iSO.32bit-LiNUX-0171-bt5r2gis32.par2.nzb"); > httpget.setHeader("Accept-Encoding", "gzip"); > HttpClient client = HttpClientBuilder.create().build(); > HttpResponse response = client.execute(httpget); > HttpEntity entity = response.getEntity(); > byte[] data = EntityUtils.toByteArray( entity ); > Assert.assertEquals( data.length, 423548 ); > } > {code} > Thanks -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org