Reading chunked data from HttpEntity
- by Gagan
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 ?