0
android HttpGet
및 HttpClient
을 사용하여 다음 http 요청을하고 있습니다.http 요청 소요 시간 계산 [Android]
long startTime = System.currentTimeMillis();
HttpResponse response = httpclient.execute(httpGetReq);
HttpEntity httpEntity = response.getEntity();
long endTime = System.currentTimeMillis();
double totalTime = endTime-startTime;
이 http 요청에는 재생로드 데이터가 있습니다. 위의 코드에서이 요청에 걸리는 시간을 계산하려고하지만 위의 코드는 요청의 데이터/페이로드 부분이 아닌 헤더 부분 만 수신하는 시간을 반환합니다.
내가 원하는 것은,이 요청을 실행하는 데 걸린 총 시간을 계산하려면 모든 헤더 + 페이로드 데이터를받을 때까지의 총 시간을 의미합니다.
어떻게 보관해야합니까?
이렇게 할 수있는 몇 가지 예제 코드를 게시 할 수 있습니까? – User7723337
InputStream inputStream = httpResponse.getEntity(). getContent(); –
한 가지 방법 : EntityUtils.toString (httpResponse.getEntity()) –