line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*-
|
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
7790
|
use strict;
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
120
|
|
4
|
4
|
|
|
4
|
|
1571
|
use XML::EP::Config ();
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
120
|
|
5
|
4
|
|
|
4
|
|
2530
|
use XML::EP::Control ();
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use XML::EP::Error ();
|
7
|
|
|
|
|
|
|
use XML::EP::Response ();
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package XML::EP;
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$XML::EP::VERSION = '0.01';
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new {
|
15
|
|
|
|
|
|
|
my $proto = shift;
|
16
|
|
|
|
|
|
|
my $self = (@_ == 1) ? \%{ shift() } : { @_ };
|
17
|
|
|
|
|
|
|
bless($self, (ref($proto) || $proto));
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub MakeConfig {
|
21
|
|
|
|
|
|
|
my $self = shift;
|
22
|
|
|
|
|
|
|
my $request = $self->{request};
|
23
|
|
|
|
|
|
|
my $config = ($self->{config} ||= $XML::EP::Config::config || []);
|
24
|
|
|
|
|
|
|
my $cfg = {};
|
25
|
|
|
|
|
|
|
foreach my $c (@$config) {
|
26
|
|
|
|
|
|
|
if (my $vhost = $c->{"match_virtual_host"}) {
|
27
|
|
|
|
|
|
|
my $vh = $request->VirtualHost();
|
28
|
|
|
|
|
|
|
next if !$vh || $vh !~ /$vhost/;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
if (my $loc = $c->{"match_location"}) {
|
31
|
|
|
|
|
|
|
my $lc = $request->Location();
|
32
|
|
|
|
|
|
|
next if !$lc || $lc !~ /$loc/;
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
if (my $client = $c->{"match_client"}) {
|
35
|
|
|
|
|
|
|
my $cl = $request->Client();
|
36
|
|
|
|
|
|
|
next if !$cl || $cl !~ /$client/;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
while (my($key, $var) = each %$c) {
|
39
|
|
|
|
|
|
|
$cfg->{$key} = $var;
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
$self->{cfg} = $cfg;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub Control {
|
46
|
|
|
|
|
|
|
my $self = shift;
|
47
|
|
|
|
|
|
|
my $class = $self->{cfg}->{Controller} || "XML::EP::Control";
|
48
|
|
|
|
|
|
|
$class->new();
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
{
|
52
|
|
|
|
|
|
|
my %loaded;
|
53
|
|
|
|
|
|
|
sub Require {
|
54
|
|
|
|
|
|
|
my $self = shift; my $class = shift;
|
55
|
|
|
|
|
|
|
return if $loaded{$class};
|
56
|
|
|
|
|
|
|
my $cl = "$class.pm";
|
57
|
|
|
|
|
|
|
$cl =~ s/\:\:/\//g;
|
58
|
|
|
|
|
|
|
require $cl;
|
59
|
|
|
|
|
|
|
$loaded{$class} = $cl;
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub Handle {
|
64
|
|
|
|
|
|
|
my $self = shift; $self->{request} = shift;
|
65
|
|
|
|
|
|
|
$self->{response} = XML::EP::Response->new();
|
66
|
|
|
|
|
|
|
eval {
|
67
|
|
|
|
|
|
|
$self->MakeConfig();
|
68
|
|
|
|
|
|
|
my $control = $self->Control();
|
69
|
|
|
|
|
|
|
my $xml = $control->CreatePipe($self);
|
70
|
|
|
|
|
|
|
while (my $p = shift @{$self->{processors}}) {
|
71
|
|
|
|
|
|
|
if (!ref($p)) {
|
72
|
|
|
|
|
|
|
$self->Require($p);
|
73
|
|
|
|
|
|
|
$p = $p->new();
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
$xml = $p->Process($self, $xml);
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
my $formatter = $self->{formatter};
|
78
|
|
|
|
|
|
|
$self->Require($formatter);
|
79
|
|
|
|
|
|
|
$self->{formatter}->Format($self, $xml);
|
80
|
|
|
|
|
|
|
};
|
81
|
|
|
|
|
|
|
$@
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub Processors {
|
85
|
|
|
|
|
|
|
my $self = shift;
|
86
|
|
|
|
|
|
|
@_ ? ($self->{processors} = shift) : $self->{processors};
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub Formatter {
|
90
|
|
|
|
|
|
|
my $self = shift;
|
91
|
|
|
|
|
|
|
@_ ? ($self->{formatter} = shift) : $self->{formatter};
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub Request {
|
95
|
|
|
|
|
|
|
my $self = shift;
|
96
|
|
|
|
|
|
|
@_ ? ($self->{request} = shift) : $self->{request};
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub Response {
|
100
|
|
|
|
|
|
|
my $self = shift;
|
101
|
|
|
|
|
|
|
@_ ? ($self->{response} = shift) : $self->{response};
|
102
|
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1;
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__
|