DelphiFAQ Home Search:

Apache's access control passed multiple times during multi-part downloads

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Question:

We are using Apache and use perl module AuthCookie.pm for access control (authentication, authorization). We log all accesses into a mysql database. When users download large documents, I see multiple entries per downloaded document in our database - typically 6 to 12 entries. I see the corresponding log file entries with an http result code of 206 (partial download).

How can I log only the first of those 6 to 12 partial downloads?

Answer:

From the authentication/ authorization code you have access to Apache's RequestRec object. You can see the headers there. One of the headers will be Range (in case a part of the file is requested. Look at the code below - it shows how to access the incoming headers (all of them) and in particular how to check if a request is a subsequent partial download.

my $headers_in = $r->headers_in();
while(my($k,$v) = each %$headers_in) {
   print LOGFILE "$k = $v\n";
}

if ($r->headers_in->get('Range') eq '') {
  # process only for the first (non partial) request
}

Comments:

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: