Reading chunked data from HttpEntity
I have the following code:
开发者_StackOverflow中文版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 ?
Shouldn't you use writeTo? The docs say:
Writes the entity content to the output stream.
精彩评论