| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Apache2::ASP::Mock::RequestRec; |
|
3
|
|
|
|
|
|
|
|
|
4
|
23
|
|
|
23
|
|
107
|
use strict; |
|
|
23
|
|
|
|
|
34
|
|
|
|
23
|
|
|
|
|
639
|
|
|
5
|
23
|
|
|
23
|
|
83
|
use warnings 'all'; |
|
|
23
|
|
|
|
|
28
|
|
|
|
23
|
|
|
|
|
839
|
|
|
6
|
23
|
|
|
23
|
|
80
|
use Carp 'confess'; |
|
|
23
|
|
|
|
|
32
|
|
|
|
23
|
|
|
|
|
953
|
|
|
7
|
23
|
|
|
23
|
|
8225
|
use Apache2::ASP::Mock::Connection; |
|
|
23
|
|
|
|
|
37
|
|
|
|
23
|
|
|
|
|
539
|
|
|
8
|
23
|
|
|
23
|
|
7688
|
use Apache2::ASP::Mock::Pool; |
|
|
23
|
|
|
|
|
38
|
|
|
|
23
|
|
|
|
|
553
|
|
|
9
|
23
|
|
|
23
|
|
103
|
use HTTP::Headers; |
|
|
23
|
|
|
|
|
27
|
|
|
|
23
|
|
|
|
|
13223
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#============================================================================== |
|
13
|
|
|
|
|
|
|
sub new |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
0
|
|
|
0
|
0
|
|
my ($class) = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $s = bless { |
|
18
|
|
|
|
|
|
|
buffer => '', |
|
19
|
|
|
|
|
|
|
uri => '', |
|
20
|
|
|
|
|
|
|
headers_out => HTTP::Headers->new, |
|
21
|
|
|
|
|
|
|
headers_in => { }, |
|
22
|
|
|
|
|
|
|
pnotes => { }, |
|
23
|
|
|
|
|
|
|
status => 200, |
|
24
|
|
|
|
|
|
|
cleanup_handlers => [ ], |
|
25
|
|
|
|
|
|
|
pool => Apache2::ASP::Mock::Pool->new(), |
|
26
|
|
|
|
|
|
|
connection => Apache2::ASP::Mock::Connection->new(), |
|
27
|
|
|
|
|
|
|
}, $class; |
|
28
|
0
|
|
|
|
|
|
$s->{err_headers_out} = $s->{headers_out}; |
|
29
|
0
|
|
|
|
|
|
return $s; |
|
30
|
|
|
|
|
|
|
}# end new() |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#============================================================================== |
|
34
|
|
|
|
|
|
|
sub push_handlers |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
0
|
|
|
0
|
0
|
|
my ($s, $ref, @args) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
push @{$s->{cleanup_handlers}}, { |
|
|
0
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
subref => $ref, |
|
40
|
|
|
|
|
|
|
args => \@args, |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
}# end push_handlers() |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#============================================================================== |
|
46
|
|
|
|
|
|
|
sub filename |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $config = Apache2::ASP::HTTPContext->current->config; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $config->web->www_root . $s->uri; |
|
53
|
|
|
|
|
|
|
}# end filename() |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#============================================================================== |
|
57
|
|
|
|
|
|
|
sub pnotes |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
60
|
0
|
|
|
|
|
|
my $key = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
@_ ? $s->{pnotes}->{$key} = shift : $s->{pnotes}->{$key}; |
|
63
|
|
|
|
|
|
|
}# end pnotes() |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#============================================================================== |
|
67
|
|
|
|
|
|
|
sub buffer |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
0
|
|
|
0
|
1
|
|
$_[0]->{buffer}; |
|
70
|
|
|
|
|
|
|
}# end buffer() |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#============================================================================== |
|
74
|
|
|
|
|
|
|
sub pool |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
0
|
1
|
|
$_[0]->{pool}; |
|
77
|
|
|
|
|
|
|
}# end buffer() |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#============================================================================== |
|
81
|
|
|
|
|
|
|
sub status |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
@_ ? $s->{status} = shift : $s->{status}; |
|
86
|
|
|
|
|
|
|
}# end status() |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#============================================================================== |
|
90
|
|
|
|
|
|
|
sub uri |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
if( @_ ) |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
0
|
|
|
|
|
|
$s->{uri} = shift; |
|
97
|
|
|
|
|
|
|
# Should we also set $ENV{REQUEST_URI} here? |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
else |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
0
|
|
|
|
|
|
return $s->{uri}; |
|
102
|
|
|
|
|
|
|
}# end if() |
|
103
|
|
|
|
|
|
|
}# end uri() |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#============================================================================== |
|
107
|
|
|
|
|
|
|
sub args |
|
108
|
|
|
|
|
|
|
{ |
|
109
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
110
|
0
|
0
|
|
|
|
|
@_ ? $s->{args} = shift : $s->{args}; |
|
111
|
|
|
|
|
|
|
}# end args() |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#============================================================================== |
|
115
|
|
|
|
|
|
|
sub method |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
118
|
0
|
0
|
|
|
|
|
@_ ? $s->{method} = shift : $s->{method}; |
|
119
|
|
|
|
|
|
|
}# end method() |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#============================================================================== |
|
123
|
|
|
|
|
|
|
#XXX Not documented. |
|
124
|
|
|
|
|
|
|
sub headers_out |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
0
|
|
|
0
|
0
|
|
$_[0]->{headers_out}; |
|
127
|
|
|
|
|
|
|
}# end headers_out() |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#============================================================================== |
|
131
|
|
|
|
|
|
|
#XXX Not documented. |
|
132
|
|
|
|
|
|
|
sub err_headers_out |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
0
|
|
|
0
|
0
|
|
$_[0]->{headers_out}; |
|
135
|
|
|
|
|
|
|
}# end err_headers_out() |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#============================================================================== |
|
139
|
|
|
|
|
|
|
#XXX Not documented. |
|
140
|
|
|
|
|
|
|
sub headers_in |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
0
|
|
|
0
|
0
|
|
$_[0]->{headers_in}; |
|
143
|
|
|
|
|
|
|
}# end headers_out() |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#============================================================================== |
|
147
|
|
|
|
|
|
|
#XXX Not documented. |
|
148
|
|
|
|
|
|
|
sub send_headers |
|
149
|
|
|
|
|
|
|
{ |
|
150
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $buffer = delete($s->{buffer}); |
|
153
|
0
|
|
|
|
|
|
$s->print( join "\n", map { "$_: $s->{headers_out}->{$_}" } keys(%{$s->{headers_out}}) ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
$s->{buffer} = $buffer; |
|
155
|
|
|
|
|
|
|
}# end send_headers() |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#============================================================================== |
|
159
|
|
|
|
|
|
|
sub content_type |
|
160
|
|
|
|
|
|
|
{ |
|
161
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
162
|
0
|
0
|
|
|
|
|
@_ ? $s->{content_type} = shift : $s->{content_type}; |
|
163
|
|
|
|
|
|
|
}# end content_type() |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#============================================================================== |
|
167
|
|
|
|
|
|
|
sub print |
|
168
|
|
|
|
|
|
|
{ |
|
169
|
0
|
|
|
0
|
1
|
|
$_[0]->{buffer} .= $_[1]; |
|
170
|
|
|
|
|
|
|
}# end print() |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
#============================================================================== |
|
174
|
|
|
|
|
|
|
sub rflush |
|
175
|
|
|
|
|
|
|
{ |
|
176
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
|
177
|
|
|
|
|
|
|
#warn "$s: rflush()"; |
|
178
|
|
|
|
|
|
|
}# end rflush() |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
#============================================================================== |
|
182
|
|
|
|
|
|
|
sub connection |
|
183
|
|
|
|
|
|
|
{ |
|
184
|
0
|
|
|
0
|
1
|
|
$_[0]->{connection}; |
|
185
|
|
|
|
|
|
|
}# end connection() |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
#============================================================================== |
|
189
|
|
|
|
|
|
|
sub document_root |
|
190
|
|
|
|
|
|
|
{ |
|
191
|
0
|
|
|
0
|
0
|
|
$ENV{DOCUMENT_ROOT}; |
|
192
|
|
|
|
|
|
|
}# end document_root() |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1;# return true: |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=pod |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 NAME |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Apache2::ASP::Mock::RequestRec - Mimics the mod_perl2 Apache2::RequestRec object ($r) |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $r = Apache2::ASP::HTTPContext->current->r; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$r->filename( '/index.asp' ); # '/usr/local/projects/mysite.com/htdocs/index.asp |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
$r->pnotes( foo => 'bar' ); # set foo = 'bar' |
|
209
|
|
|
|
|
|
|
my $foo = $r->pnotes( 'foo' ); # get foo |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $output_buffer_contents = $r->buffer; |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
my $mock_apr_pool = $r->pool; |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$r->status( '302 Found' ); |
|
216
|
|
|
|
|
|
|
my $status = $r->status; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $uri = $r->uri; |
|
219
|
|
|
|
|
|
|
$r->uri('/new.asp'); |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
my $method = $r->method; # get/post |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
$r->content_type( 'text/html' ); |
|
224
|
|
|
|
|
|
|
my $type = $r->content_type; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
my $mock_connection = $r->connection; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
$r->print( 'some string' ); |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
$r->rflush; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This package provides "mock" access to what would normally be an L object - |
|
235
|
|
|
|
|
|
|
known by the name C<$r> in a normal mod_perl2 environment. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This package exists only to provide a layer of abstraction for L |
|
238
|
|
|
|
|
|
|
and L. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
B: The purpose of this package is only to mimic I of the functionality |
|
241
|
|
|
|
|
|
|
of L to B without it - specifically during testing. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
If you require additional functionality, B |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 PUBLIC PROPERTIES |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 filename |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Read-only. Returns the absolute filename for the current request - i.e. C |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 pnotes( $name [, $value ] ) |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Read/Write. Set or get a variable for the duration of the current request. |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 buffer |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Read-only. Returns the contents of the current output buffer. |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 pool |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Read-only. Returns the current L object. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head2 status( [$new_status] ) |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Read/Write. Set or get the HTTP status code, I L. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head2 uri( [$new_uri] ) |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Read/Write. Set or get the request URI. |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head2 method |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Read-only. Gets the request method - i.e. 'get' or 'post'. |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head2 content_type( [$new_content_type] ) |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Read/Write. Set or get the B C header. |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 connection |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Read-only. Returns the current L object. |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head2 print( $string ) |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Adds C<$string> to the output buffer. |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head2 rflush( ) |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Does nothing. Here only to maintain compatibility with a normal mod_perl2 environment. |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head1 BUGS
|
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
It's possible that some bugs have found their way into this release.
|
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Use RT L to submit bug reports.
|
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head1 HOMEPAGE
|
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Please visit the Apache2::ASP homepage at L to see examples
|
|
302
|
|
|
|
|
|
|
of Apache2::ASP in action. |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head1 AUTHOR |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
John Drago |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Copyright 2008 John Drago. All rights reserved. |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head1 LICENSE |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
This software is Free software and is licensed under the same terms as perl itself. |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
|
317
|
|
|
|
|
|
|
|