Reading chunked data from HttpEntity
Posted
by Gagan
on Stack Overflow
See other posts from Stack Overflow
or by Gagan
Published on 2010-05-18T22:04:39Z
Indexed on
2010/05/18
22:10 UTC
Read the original article
Hit count: 303
http
|httpclient
I have the following code:
HttpClient FETCHER
HttpResponse response = FETCHER.execute(host, httpMethod);
Im trying to read its contents to a string like this:
HttpEntity entity = response.getEntity();
InputStream st = entity.getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(st, writer);
String content = writer.toString();
The problem is, when i fetch http://www.google.co.in/ page, the transfer encoding is chunked, and i get only the first chunk. It fetches till first "".
How do i get all the chunks at once so i can dump the complete output and do some processing on it ?
© Stack Overflow or respective owner