开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜