I'm a bit confused when making a http connection. I want to know at what place in code the data from the server has finished downloading on the phone, client?
I have the following code, standard http java connection code:
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
} catch (Exception e) {
e.printStackTrace();
}
}
so the question is what actually happens in:
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
IS all of the server data downloaded in this place or can it happened that data from the server is still arriving in the while block
while ((s = buffer.readLine()) != null) {
response += s;
}
My understanding is that the connection is still alive in the:
while ((s = buffer.readLine()) != null) {
response += s;
}
and more data can come while the socket is been read. I know this since I have been using the stream to handle bid data, like movies, drawing big routes or things that should be shown as the come.