line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::DumpHeaders; |
2
|
1
|
|
|
1
|
|
727
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
1614
|
use Apache; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Apache::Constants qw(DECLINED OK); |
5
|
|
|
|
|
|
|
use vars qw($VERSION); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = "0.94"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub handler { |
10
|
|
|
|
|
|
|
my $r = shift; |
11
|
|
|
|
|
|
|
my $note = $r->notes("DumpHeaders"); |
12
|
|
|
|
|
|
|
if ($r->dir_config("DumpHeaders_Conditional")) { |
13
|
|
|
|
|
|
|
return DECLINED unless $note; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
if ($r->dir_config("DumpHeaders_Percent")) { |
16
|
|
|
|
|
|
|
return DECLINED unless rand(100) < $r->dir_config("DumpHeaders_Percent"); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
if ($r->dir_config("DumpHeaders_IP")) { |
19
|
|
|
|
|
|
|
my $remote_ip = $r->connection->remote_ip; |
20
|
|
|
|
|
|
|
return DECLINED unless grep { /\Q$remote_ip\E/ } |
21
|
|
|
|
|
|
|
split (/\s+/, $r->dir_config("DumpHeaders_IP")); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
my $filename = $r->dir_config("DumpHeaders_File") or return DECLINED; |
24
|
|
|
|
|
|
|
unless (open OUT, ">>$filename") { |
25
|
|
|
|
|
|
|
warn "Failed to open $filename: $!"; |
26
|
|
|
|
|
|
|
return DECLINED; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
my $msg = ($note and $note =~ /\D/) ? "$note " : ""; |
29
|
|
|
|
|
|
|
print OUT "\n======= ", scalar localtime, " $msg=======\n"; |
30
|
|
|
|
|
|
|
print OUT $r->as_string; |
31
|
|
|
|
|
|
|
close OUT; |
32
|
|
|
|
|
|
|
return OK; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |