You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by CodingForever <ni...@gmail.com> on 2011/02/15 16:38:50 UTC

Gzip problem ?

Hi, there

I am using a piece of code(thanks to oleg) for decoding html data. (chunked
or  gzipped vs. ) 
when I try to decode the gzipped data it does not work. That gives me
gzipped data.
- I looked the header it contains Content-Encoding: gzip
What is the problem ? 


SessionInputBuffer inbuffer = new SessionInputBufferMockup(bytes);
HttpResponseParser parser = new HttpResponseParser(inbuffer,
BasicLineParser.DEFAULT, new DefaultHttpResponseFactory(), new
BasicHttpParams());
HttpResponse response = (HttpResponse) parser.parse();
EntityDeserializer deserializer = new EntityDeserializer(new
LaxContentLengthStrategy());
HttpEntity entity = deserializer.deserialize(inbuffer, response);
response.setEntity(entity);
BasicHttpContext context = new BasicHttpContext();
ResponseContentEncoding processor = new ResponseContentEncoding();
processor.process(response, context);
System.out.println(EntityUtils.toString(entity));
-- 
View this message in context: http://old.nabble.com/Gzip-problem---tp30932014p30932014.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Gzip problem ?

Posted by CodingForever <ni...@gmail.com>.
Thanks oleg, I will ask you one more question.
My chunked data consists of multi parts. This code needs complete response.
So throws error.
How can I solve this ?

olegk wrote:
> 
> On Tue, 2011-02-15 at 07:38 -0800, CodingForever wrote:
>> Hi, there
>> 
>> I am using a piece of code(thanks to oleg) for decoding html data.
>> (chunked
>> or  gzipped vs. ) 
>> when I try to decode the gzipped data it does not work. That gives me
>> gzipped data.
>> - I looked the header it contains Content-Encoding: gzip
>> What is the problem ? 
>> 
>> 
>> SessionInputBuffer inbuffer = new SessionInputBufferMockup(bytes);
>> HttpResponseParser parser = new HttpResponseParser(inbuffer,
>> BasicLineParser.DEFAULT, new DefaultHttpResponseFactory(), new
>> BasicHttpParams());
>> HttpResponse response = (HttpResponse) parser.parse();
>> EntityDeserializer deserializer = new EntityDeserializer(new
>> LaxContentLengthStrategy());
>> HttpEntity entity = deserializer.deserialize(inbuffer, response);
>> response.setEntity(entity);
>> BasicHttpContext context = new BasicHttpContext();
>> ResponseContentEncoding processor = new ResponseContentEncoding();
>> processor.process(response, context);
>> System.out.println(EntityUtils.toString(entity));
> 
> My bad. The last line should be  
> 
> System.out.println(EntityUtils.toString(response.getEntity()));
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Re%3A-Gzip-problem---tp30932102p30932234.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Gzip problem ?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2011-02-15 at 07:38 -0800, CodingForever wrote:
> Hi, there
> 
> I am using a piece of code(thanks to oleg) for decoding html data. (chunked
> or  gzipped vs. ) 
> when I try to decode the gzipped data it does not work. That gives me
> gzipped data.
> - I looked the header it contains Content-Encoding: gzip
> What is the problem ? 
> 
> 
> SessionInputBuffer inbuffer = new SessionInputBufferMockup(bytes);
> HttpResponseParser parser = new HttpResponseParser(inbuffer,
> BasicLineParser.DEFAULT, new DefaultHttpResponseFactory(), new
> BasicHttpParams());
> HttpResponse response = (HttpResponse) parser.parse();
> EntityDeserializer deserializer = new EntityDeserializer(new
> LaxContentLengthStrategy());
> HttpEntity entity = deserializer.deserialize(inbuffer, response);
> response.setEntity(entity);
> BasicHttpContext context = new BasicHttpContext();
> ResponseContentEncoding processor = new ResponseContentEncoding();
> processor.process(response, context);
> System.out.println(EntityUtils.toString(entity));

My bad. The last line should be  

System.out.println(EntityUtils.toString(response.getEntity()));


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org