I am working with this problem on Android, but it is not a problem with Android.
Using org.apache.http.client.HttpClient, I can make a request for a 1kb URL, and the whole answer is in the HttpResponse:
HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://10.16.83.67/1kb.log"); HttpResponse response = null; BufferedReader rd = null; response = client.execute(request);
Then I can get HttpEntity from the response:
HttpEntity entity = response.getEntity(); rd = new BufferedReader(new InputStreamReader(entity.getContent()));
And then, with BufferedReader ...
while ((line = rd.readLine()) != null) {
I look at WireShark, and I see that there is one transmission in each direction for the above code: a request for a log file, and then the whole response is delivered in response.
However, if I ask for something more, say my log file is 1 MB, I see something completely different. Data is placed in frames and then transmitted over the cable in an rd.readLine() loop.

It seems the first kb or so is included in the original answer. But then, when readLine() started, it calls additional requests to the server, and the data is transferred to the socket. If the network connection is interrupted, I get an I / O error. For large queries, entity.isStreaming() is true .
This is an asynchronous call (mandatory for Android, since network calls cannot be made in the UI thread), but I donβt want to continue until Iβm sure that I still get all the data from this request, Just wait for the time, and then continue and hoping for the best, unfortunately, is not an option.
My question is this: Do HttpClient , HttpGet , HttpResponse or HttpEntity when they receive data from this request? Or do I need to rely on BufferedReader to find out when a thread is closed?