Reading fragmented data from HttpEntity

I have the following code:

HttpClient FETCHER HttpResponse response = FETCHER.execute(host, httpMethod); 

I am trying to read its contents in a line 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 that when I retrieve http://www.google.co.in/ , the transfer encoding is blocked and I get only the first fragment. He chooses before the first. "

How can I get all the pieces at once so that I can flush the full output and do some processing on it?

+4
source share
1 answer

Should I use writeTo? The docs say:

Writes the contents of an object to the output stream.

+1
source

Source: https://habr.com/ru/post/1310178/


All Articles