I want to retrieve the file sizes of multiple urls. As of now, this is what I'm doing:
for ( int i = 0; i < urls.length; i++ ) {
url = urls[i];
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod( "HEAD" );
fileSizes[i] = conn.getContentLength();
}
But I think this is inefficient as it goes back and forth (request then a response, and over again).
Now, is there a way that I can perform a batch request for all those urls, so that the response will contain the file sizes of all those urls (only one request and one response)?
Also, I'm an absolute beginner in HTTP connections thus I don't even know if the title of this post is correct.