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 0978910678 for ; Fri, 21 Feb 2014 10:48:24 +0000 (UTC) Received: (qmail 40085 invoked by uid 500); 21 Feb 2014 10:48:23 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 39853 invoked by uid 500); 21 Feb 2014 10:48:21 -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 39820 invoked by uid 99); 21 Feb 2014 10:48:19 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Feb 2014 10:48:19 +0000 Date: Fri, 21 Feb 2014 10:48:19 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (HTTPCLIENT-1465) IOException when reading gziped content from site. 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-1465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oleg Kalnichevski resolved HTTPCLIENT-1465. ------------------------------------------- Resolution: Not A Problem bq. But web browser and wget works fine on that site. So what? We do not really know if those applications simply quietly ignore the problem, do we? Likewise, one can catch EOFException exception and try to use whatever data have been received up to this point. By the way, I also tried to use Commons Compress (which is believed to be able to handle various corner cases better) instead of the internal JRE gzip decompressor and got exactly the same result. This really seems to support my assertion that the blame here lies with the server. {noformat} Exception in thread "main" java.io.EOFException at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290) at org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream.read(GzipCompressorInputStream.java:283) at java.io.InputStream.read(InputStream.java:101) at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:68) {noformat} > IOException when reading gziped content from site. > -------------------------------------------------- > > Key: HTTPCLIENT-1465 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1465 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.3.2 > Reporter: Igor Skakov > Priority: Minor > > Some description: > IOException when reading gziped content from site. > But web browser and wget works fine on that site. > Source code: > public class Http { > public static void main(String[] args) throws Exception { > HttpClient hc = HttpClients.createDefault(); > HttpHost host = new HttpHost("mail.ru"); > HttpGet hget = new HttpGet("/"); > HttpResponse response = hc.execute(host, hget); > HttpEntity entity = response.getEntity(); > InputStream is = entity.getContent(); > BufferedInputStream bis = new BufferedInputStream(is); > > byte[] buffer = new byte[4096]; > int readed = -1; > > while((readed = bis.read(buffer)) != -1) { > > } > > //System.out.println(body); > } > } > Error: > Exception in thread "main" java.io.IOException: Attempted read on closed stream. > at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:109) > at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:118) > at java.io.SequenceInputStream.read(Unknown Source) > at java.io.SequenceInputStream.read(Unknown Source) > at java.util.zip.GZIPInputStream.readUByte(Unknown Source) > at java.util.zip.GZIPInputStream.readUShort(Unknown Source) > at java.util.zip.GZIPInputStream.readUInt(Unknown Source) > at java.util.zip.GZIPInputStream.readTrailer(Unknown Source) > at java.util.zip.GZIPInputStream.read(Unknown Source) > at java.util.zip.InflaterInputStream.read(Unknown Source) > at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:56) > at java.io.InputStream.read(Unknown Source) > at java.io.BufferedInputStream.fill(Unknown Source) > at java.io.BufferedInputStream.read1(Unknown Source) > at java.io.BufferedInputStream.read(Unknown Source) > at java.io.FilterInputStream.read(Unknown Source) > at Http.main(Http.java:26) > Version 4.3.2 -- This message was sent by Atlassian JIRA (v6.1.5#6160) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org