File: RedirectLogFix.pm

package info (click to toggle)
libapache-mod-perl 1.16-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,580 kB
  • ctags: 1,064
  • sloc: ansic: 4,489; perl: 4,415; sh: 305; makefile: 137
file content (35 lines) | stat: -rw-r--r-- 697 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package Apache::RedirectLogFix;

use Apache::Constants qw(OK DECLINED REDIRECT);

sub handler {
    my $r = shift;
    return DECLINED unless $r->handler && ($r->handler eq "perl-script");

    if(my $loc = $r->header_out("Location")) {
	if($r->status == 200 and substr($loc, 0, 1) ne "/") {
	    $r->status(REDIRECT);
	    return OK
	}
    }
    return DECLINED;
}

1;

__END__

=head1 NAME

Apache::RedirectLogFix - Properly set redirect status for loggers

=head1 SYNOPSIS

PerlLogHandler Apache::RedirectLogFix

=head1 DESCRIPTION

Due the nature of how mod_perl handles redirects, the status code
is not properly logged.  This module works around that bug until
mod_perl can deal with this.