Fedora Linux Support Community & Resources Center
Old 26th May 2010, 09:40 AM
Jamwa Offline
Registered User
Join Date: Jan 2008
Location: Nairobi Kenya
Posts: 565
Apache/Tomcat Size Of File Transfered

Am looking to determine how much of a file was downloaded in either Apache or Tomcat web servers.

Looking at a sample entry on the Apache log files:

Code: - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
The last entry shows the size of the object returned to the client. So suppose I have placed a downloadable 3kb file on the server, and the user downloads only 1kb of it, I would like it to show 1000 not 3000 as it shows, regardless.

Any help please?
Reply With Quote
Old 26th May 2010, 01:36 PM
cliff76 Offline
Registered User
Join Date: May 2005
Location: PA
Age: 41
Posts: 14
Re: Apache/Tomcat Size Of File Transfered

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:
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) {
  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.
:eek: Holla' at me... :cool:
Reply With Quote

apache or tomcat, file, size, transfered

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjusting apache log file size and rotation. millerdc Using Fedora 1 6th December 2006 06:35 AM
Apache file size limitations centos_x Servers & Networking 4 25th August 2005 01:22 AM
FC2 + Apache 2 + Tomcat 5 LeAkEd Guides & Solutions (Not For Questions) 2 27th June 2005 09:55 AM
max file size >2Gbyte in apache and pureftpd limit netblues Servers & Networking 0 4th January 2005 08:59 PM

Current GMT-time: 09:07 (Tuesday, 22-08-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat