Hi all,
First of all, I enjoy the library a lot. I have been noticing some strange
behavior with a chunked gzip response, though, and wanted to run it by some
users before crying bug.
First, the offending code snippet:
String url = "
http://173.193.248.156:8080/x/brs1013?aid=eedcd7b2-001a-4388-9415-f2cd697d7608&buid=&ip=209.117.114.63&ua=Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US;+rv:1.9.2.15)+Gecko/20110303+Firefox/3.6.15&lang=en_US&url=http://minifb-parking.mindjolt.com/fb/game_iframehtmlad.jsp?gkey=FRZ7GJK9OLYE2VMS&gcat=action>itle=Parking+Mania&gdesc=Park+the+car+without+crashing+it.&ts=1299189609250&ad_duration=30&top=true&site=mindjolt.com&pid=9234&frmts=linear15:300x250,linear15&cat=games:casual_games&qual=
";
HttpClient httpClient = new ContentEncodingHttpClient();
HttpGet get = new HttpGet(url);
String content = httpClient.execute(get, new BasicResponseHandler());
When calling execute(), the following is thrown:
java.io.IOException: Attempted read from closed stream.
at
org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:126)
at java.util.zip.CheckedInputStream.read(CheckedInputStream.java:42)
at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:205)
at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:197)
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:136)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
at java.util.zip.GZIPInputStream.<init>(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)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:974)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:919)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:910)
at tv.adap.service.HttpPoolTest.testChunkedGzip(HttpPoolTest.java:41)
...
As far as I can tell, this is unexpected behavior. The output of:
curl -H "Accept-Encoding: gzip,deflate" "
http://173.193.248.156:8080/x/brs1013?aid=eedcd7b2-001a-4388-9415-f2cd697d7608&buid=&ip=209.117.114.63&ua=Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US;+rv:1.9.2.15)+Gecko/20110303+Firefox/3.6.15&lang=en_US&url=http://minifb-parking.mindjolt.com/fb/game_iframehtmlad.jsp?gkey=FRZ7GJK9OLYE2VMS&gcat=action>itle=Parking+Mania&gdesc=Park+the+car+without+crashing+it.&ts=1299189609250&ad_duration=30&top=true&site=mindjolt.com&pid=9234&frmts=linear15:300x250,linear15&cat=games:casual_games&qual="
| gunzip -
looks just fine.
Is this a bug, or am I using HttpClient incorrectly? I'm using HttpClient
4.1 on Mac OS X 10.6.6.
java -version output:
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
Let me know if I omitted anything valuable in answering my question.
Thanks in advance,
Adam Hahn