My guess is that you'd need some custom servlet logic. A servlet could respond to the file request incrementally read/write the file to the response.outputStream and count the bytes transferred and write the total to a log file. On the cases where the client closes the connection prematurely the servlet would have to catch the IOException (I believe its manifests as a broken pipe exception) and respond accordingly. It might look something like:
Code:
long bytesXferred = 0;
try {
FileInputStream responseFile = getResponseFileFromRequest(request);
for(int count = responseFile.read(buffer, 0, buffer.length); count !=-1; count = responseFile.read(buffer, 0, buffer.length)) {
response.getOutputStream.write(buffer, 0, buffer.length);
}
}catch(IOException e) {
}finally{
getLogger().log("Transferred " + bytesXFerred + " bytes.");
}
Now that I think of it, using the approach in the above sample (written completely ad-hoc and untested) would likely yield in an HTTP chunk-file transfer where content length is unknown while it is delivered in chunks. Each chunk size would show in your logs which could be inspected to derive the total size.