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 304AFEB8F for ; Wed, 30 Jan 2013 17:07:16 +0000 (UTC) Received: (qmail 24069 invoked by uid 500); 30 Jan 2013 17:07:14 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 24029 invoked by uid 500); 30 Jan 2013 17:07:14 -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 23966 invoked by uid 99); 30 Jan 2013 17:07:14 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jan 2013 17:07:14 +0000 Date: Wed, 30 Jan 2013 17:07:14 +0000 (UTC) From: "Nikola Petrov (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HTTPCLIENT-1312) Decompressing on redirects with redirection support off doesn't work properly 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-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13566626#comment-13566626 ] Nikola Petrov commented on HTTPCLIENT-1312: ------------------------------------------- I suspected that it might be linkedin's fault. I also saw the content-length: 0 but thought that httpclient should check the content size before passing it to GZipInputStream which checks for a magical header in the opening phase. Thanks for the quick response. Besti, Nikola > Decompressing on redirects with redirection support off doesn't work properly > ----------------------------------------------------------------------------- > > Key: HTTPCLIENT-1312 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1312 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.2.2 > Reporter: Nikola Petrov > Priority: Minor > Labels: gzip, redirect > Fix For: 4.2.4, 4.3 Alpha2 > > > We are a having a problem with the httpclient implementation on redirecting websites that support gzip encoding. The problem occurs only if the automatic redirect facilities are disabled. Here is a resulting code that fails - note that if you set the HANDLE_REDIRECTS to true it works > {code:language:java} > private static final String PROBLEMATIC_URL = "http://www.linkedin.com/companies/7099?dspporc=&trk=jobtocomp&goback=%2Efjs_*1_*1_*1_I_gb_*1_*1_1_DD_true_*1_*2_*2_3+2+1_*2_*2_*2_*2_*2"; > public static void main(String[] args) throws ClientProtocolException, > IOException { > HttpParams httpParams = new BasicHttpParams(); > httpParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); > HttpClient httpclient = new DecompressingHttpClient(new DefaultHttpClient(httpParams)); > ResponseHandler responseHandler = new ResponseHandler() { > public Void handleResponse(HttpResponse response) > throws ClientProtocolException, IOException { > response.getEntity().getContent(); > return null; > } > }; > httpclient.execute(new HttpGet(URI.create(PROBLEMATIC_URL)), > responseHandler); > } > {code} > The exception I am getting from this is the following on version 4.2.2 > Exception in thread "main" java.io.IOException: Attempted read from closed stream. > at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:138) > at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:121) > at java.util.zip.CheckedInputStream.read(CheckedInputStream.java:42) > at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:247) > at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:239) > at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:142) > at java.util.zip.GZIPInputStream.(GZIPInputStream.java:58) > at java.util.zip.GZIPInputStream.(GZIPInputStream.java:67) > at org.apache.http.client.entity.GzipDecompressingEntity.getDecompressingInputStream(GzipDecompressingEntity.java:56) > at org.apache.http.client.entity.DecompressingEntity.getContent(DecompressingEntity.java:72) > at org.apache.http.util.EntityUtils.consume(EntityUtils.java:83) > at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:176) > at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:165) > at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:153) > at com.ontotext.test.App.main(App.java:42) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators 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