User7723337
User7723337

Reputation: 12018

Calculating time taken by http request[Android]

Using android HttpGet and HttpClient i am doing following http request.

long startTime = System.currentTimeMillis();
HttpResponse response = httpclient.execute(httpGetReq);
HttpEntity httpEntity = response.getEntity();
long endTime = System.currentTimeMillis();
double totalTime = endTime-startTime;

This http request has playload data. In above code i am trying to calculate time taken by this request but, above code returns only time taken to receive header part and not data/payload part of the request.

What i want is, i want to calculate total number of time taken to execute this request, means total time till we receive all the headers + payload data.

How should i archive this?

Upvotes: 0

Views: 807

Answers (1)

Gaurav Arora
Gaurav Arora

Reputation: 1815

You'd need to get the inputStream from the response and read the input stream to judge the approximate time taken by the entire request.

Upvotes: 1

Related Questions