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 03B026C86 for ; Wed, 22 Jun 2011 11:19:09 +0000 (UTC) Received: (qmail 71003 invoked by uid 500); 22 Jun 2011 11:19:08 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 70943 invoked by uid 500); 22 Jun 2011 11:19:08 -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 70935 invoked by uid 99); 22 Jun 2011 11:19:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2011 11:19:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2011 11:19:07 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 68C6E428A0F for ; Wed, 22 Jun 2011 11:18:47 +0000 (UTC) Date: Wed, 22 Jun 2011 11:18:47 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: <1319994608.29141.1308741527425.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1485005732.26554.1308695628005.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (HTTPCLIENT-1103) GzipDecompressingEntity (and therefore ContentEncodingHttpClient) not consistent with EntityUtils.consumeEntity 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-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13053186#comment-13053186 ] Oleg Kalnichevski commented on HTTPCLIENT-1103: ----------------------------------------------- I think this issue is a duplicate of HTTPCLIENT-1075. Could you please retest your application with the latest SVN snapshot (either off trunk or 4.1.x branch) and let me know if that fixes the problem for you? Oleg > GzipDecompressingEntity (and therefore ContentEncodingHttpClient) not consistent with EntityUtils.consumeEntity > --------------------------------------------------------------------------------------------------------------- > > Key: HTTPCLIENT-1103 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1103 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.1.1 > Environment: jdk6 > Reporter: Reuben Pasquini > > Invoking EntityUtils.consume( entity ) after a previous call to entity.getContent (and subsequent processing of the content) throws a java.io.EOFException when gzip decompression support is enabled via ContentEncodingHttpClient or some similar mechanism. I invoke EntityUtils.consume in a 'finally' block - maybe I'm not using the API correctly ... ? > java.io.EOFException > at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:207) > at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:197) > at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:136) > at java.util.zip.GZIPInputStream.(GZIPInputStream.java:58) > at java.util.zip.GZIPInputStream.(GZIPInputStream.java:68) > at org.apache.http.client.entity.GzipDecompressingEntity.getContent(GzipDecompressingEntity.java:63) > at org.apache.http.conn.BasicManagedEntity.getContent(BasicManagedEntity.java:88) > at org.apache.http.util.EntityUtils.consume(EntityUtils.java:65) > I believe the problem is that the underlying DecompressingEntity allocates a new GzipInputStream for each call to getContent, rather than caching the stream created by the first getContent call. > http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java > The "CustomProtocolInterceptors" example has the same bug: http://hc.apache.org/httpcomponents-client-ga/examples.html > I worked around the problem implementing the example with my own GzipDecompressingEntity (scala code - lazy value not evaluated till accessed): > class GzipDecompressingEntity( entity:http.HttpEntity) extends http.entity.HttpEntityWrapper(entity) { > private lazy val gzipStream = new GZIPInputStream( entity.getContent() ) > > /** > * Wrap entity stream in GZIPInputStream > */ > override def getContent():java.io.InputStream = gzipStream > /** > * Return -1 - don't know unzipped content size > */ > override def getContentLength():Long = -1L > } -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org