You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Igor Skakov (JIRA)" <ji...@apache.org> on 2014/02/21 12:54:19 UTC
[jira] [Comment Edited] (HTTPCLIENT-1465) IOException when reading
gziped content from site.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13908201#comment-13908201 ]
Igor Skakov edited comment on HTTPCLIENT-1465 at 2/21/14 11:52 AM:
-------------------------------------------------------------------
I agree that it broken server behavior, but all browsers ignore this broken server behavior. In that library well be logic to switch between that broken server behavior processing - throw exception or think that stream ends and we need terminate receiving without throwing exception.
I expect that httpclient will work same as modern browsers.
https://code.google.com/p/android/issues/detail?id=61013
was (Author: igorska):
I agree that it broken server behavior, but all browsers ignore this broken server behavior. In that library well be logic to switch between that broken server behavior processing - throw exception or think that stream ends and we need terminate receiving without throwing exception.
https://code.google.com/p/android/issues/detail?id=61013
> 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