DelphiFAQ Home Search:
General :: Windows :: Apache :: mod_perl


Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

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

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
 }
 

Generated 4:02:26 on Mar 26, 2017