line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Environment::Plugin::Apache2::Apache2::Filter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
1; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Apache2::Filter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Test::Environment::Plugin::Apache2::Apache2::Filter - fake Apache2::Filter for Test::Environment |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Test::Environment qw{ |
16
|
|
|
|
|
|
|
Apache2 |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $filter = Apache2::Filter->new( |
20
|
|
|
|
|
|
|
'data' => \$data, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
is( |
24
|
|
|
|
|
|
|
My::App:Apache2::Filter::handler($filter), |
25
|
|
|
|
|
|
|
Apache2::Const::OK, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
is($$filter->r->pnotes('any_news'), 'no'); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Will populate Apache2::Filter namespace with fake methods that can be used for Apache2::Filter |
32
|
|
|
|
|
|
|
testing. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
2428
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
37
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
945
|
use IO::String; |
|
1
|
|
|
|
|
5277
|
|
|
1
|
|
|
|
|
154
|
|
42
|
1
|
|
|
1
|
|
12
|
use Carp::Clan (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
|
6
|
use base 'Class::Accessor::Fast'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1153
|
|
45
|
|
|
|
|
|
|
=head1 PROPERTIES |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
ctx |
48
|
|
|
|
|
|
|
data |
49
|
|
|
|
|
|
|
max_buffer_size |
50
|
|
|
|
|
|
|
data_for_next_filter |
51
|
|
|
|
|
|
|
seen_eos |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw{ |
56
|
|
|
|
|
|
|
ctx |
57
|
|
|
|
|
|
|
data |
58
|
|
|
|
|
|
|
max_buffer_size |
59
|
|
|
|
|
|
|
seen_eos |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 new() |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Filter object contructor. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new { |
71
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
72
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new({ |
73
|
|
|
|
|
|
|
'data' => '', |
74
|
|
|
|
|
|
|
'request_rec' => {}, |
75
|
|
|
|
|
|
|
'max_buffer_size' => 100, |
76
|
|
|
|
|
|
|
@_, |
77
|
|
|
|
|
|
|
}); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if (ref $self->data eq 'SCALAR') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->{'data'} = IO::String->new(${$self->data}); |
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif (ref $self->data eq '') { |
83
|
0
|
|
|
|
|
|
my $filename = $self->{'data'}; |
84
|
0
|
0
|
|
|
|
|
open($self->{'data'}, '<', $filename) |
85
|
|
|
|
|
|
|
or die 'failed to open "'.$filename.'": '.$!; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
elsif (eval { $self->data->can('read'); }) { |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
0
|
|
|
|
|
|
Carp::Clan::croak('wrong "data" argument passed'); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 read($bufer, $len) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Will put $len (or $self->max_bufer_size if smaller) characters from $self->data |
100
|
|
|
|
|
|
|
into the buffer. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub read { |
105
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $buffer = \$_[0]; |
108
|
0
|
|
|
|
|
|
my $len = $_[1]; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
$len = $self->max_buffer_size |
111
|
|
|
|
|
|
|
if $len > $self->max_buffer_size; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return read($self->data, $$buffer, $len); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 print(@args) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Will append @args to the $self->data_for_next_filter. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub print { |
124
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$self->{'data_for_next_filter'} .= @_; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
'man who sold the world'; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |