line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package ASP4::Mock::RequestRec; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
35
|
use strict; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
252
|
|
5
|
9
|
|
|
9
|
|
32
|
use warnings 'all'; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
229
|
|
6
|
9
|
|
|
9
|
|
2930
|
use ASP4::Mock::Pool; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
202
|
|
7
|
9
|
|
|
9
|
|
2736
|
use ASP4::Mock::Connection; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
174
|
|
8
|
9
|
|
|
9
|
|
39
|
use ASP4::ConfigLoader; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
143
|
|
9
|
9
|
|
|
9
|
|
26
|
use Scalar::Util 'weaken'; |
|
9
|
|
|
|
|
7
|
|
|
9
|
|
|
|
|
3828
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
5130
|
|
|
5130
|
0
|
14812
|
my ($class, %args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $s = bless { |
17
|
|
|
|
|
|
|
status => 200, |
18
|
|
|
|
|
|
|
content_type => 'text/plain', |
19
|
|
|
|
|
|
|
buffer => '', |
20
|
|
|
|
|
|
|
document_root => ASP4::ConfigLoader->load()->web->www_root, |
21
|
|
|
|
|
|
|
headers_in => { }, |
22
|
|
|
|
|
|
|
headers_out => { }, |
23
|
|
|
|
|
|
|
uri => $args{uri} || $ENV{REQUEST_URI}, |
24
|
|
|
|
|
|
|
args => $args{args} || $ENV{QUERY_STRING}, |
25
|
|
|
|
|
|
|
pnotes => { }, |
26
|
|
|
|
|
|
|
method => $args{method}, |
27
|
5130
|
|
33
|
|
|
13311
|
pool => ASP4::Mock::Pool->new(), |
|
|
|
66
|
|
|
|
|
28
|
|
|
|
|
|
|
connection => ASP4::Mock::Connection->new(), |
29
|
|
|
|
|
|
|
}, $class; |
30
|
5130
|
|
|
|
|
13830
|
weaken($s->{connection}); |
31
|
5130
|
|
|
|
|
5047
|
$s->{err_headers_out} = $s->{headers_out}; |
32
|
|
|
|
|
|
|
|
33
|
5130
|
|
|
|
|
6619
|
$s->{filename} = $s->document_root . $s->uri; |
34
|
|
|
|
|
|
|
|
35
|
5130
|
|
|
|
|
12041
|
return $s; |
36
|
|
|
|
|
|
|
}# end new() |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Public read-write properties: |
40
|
|
|
|
|
|
|
sub pnotes |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
0
|
1
|
0
|
my $s = shift; |
43
|
0
|
|
|
|
|
0
|
my $name = shift; |
44
|
0
|
0
|
|
|
|
0
|
@_ ? $s->{pnotes}->{$name} = shift : $s->{pnotes}->{$name}; |
45
|
|
|
|
|
|
|
}# end pnotes() |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub uri |
48
|
|
|
|
|
|
|
{ |
49
|
20512
|
|
|
20512
|
1
|
15112
|
my $s = shift; |
50
|
20512
|
50
|
|
|
|
56444
|
@_ ? $s->{uri} = shift : $s->{uri}; |
51
|
|
|
|
|
|
|
}# end uri() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub args |
54
|
|
|
|
|
|
|
{ |
55
|
8
|
|
|
8
|
1
|
11
|
my $s = shift; |
56
|
8
|
50
|
|
|
|
58
|
@_ ? $s->{args} = shift : $s->{args}; |
57
|
|
|
|
|
|
|
}# end args() |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub status { |
60
|
5122
|
|
|
5122
|
1
|
4250
|
my $s = shift; |
61
|
5122
|
50
|
|
|
|
9805
|
@_ ? $s->{status} = +shift : $s->{status}; |
62
|
|
|
|
|
|
|
}# end status() |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Public read-only properties: |
66
|
5130
|
|
|
5130
|
1
|
7679
|
sub document_root { shift->{document_root} } |
67
|
0
|
|
|
0
|
1
|
0
|
sub method { uc( shift->{method} ) } |
68
|
1
|
|
|
1
|
1
|
9
|
sub pool { shift->{pool} } |
69
|
1103
|
|
|
1103
|
1
|
2345
|
sub connection { shift->{connection} } |
70
|
11
|
|
|
11
|
1
|
124
|
sub headers_out { shift->{headers_out} } |
71
|
10238
|
|
|
10238
|
1
|
27079
|
sub err_headers_out { shift->{err_headers_out} } |
72
|
|
|
|
|
|
|
|
73
|
5130
|
|
|
5130
|
0
|
10982
|
sub buffer { shift->{buffer} } # Not documented: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Public methods: |
77
|
10276
|
|
|
10276
|
1
|
9674
|
sub print { my ($s,$str) = @_; $s->{buffer} .= $str; } |
|
10276
|
|
|
|
|
16156
|
|
78
|
5122
|
50
|
|
5122
|
1
|
3725
|
sub content_type { my $s = shift; @_ ? $s->{content_type} = +shift : $s->{content_type} } |
|
5122
|
|
|
|
|
10744
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
15398
|
1
|
|
sub rflush { } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1;# return true: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
ASP4::Mock::RequestRec - Mimic an Apache2::RequestRec object |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
When an ASP4 request is executed outside of a mod_perl2 environment, it uses an |
93
|
|
|
|
|
|
|
instance of C in place of the L it |
94
|
|
|
|
|
|
|
would otherwise have. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 PUBLIC PROPERTIES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 pnotes( $name [, $value ] ) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Sets or gets the value of a named "pnote" for the duration of the request. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Example: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$r->pnotes( foo => "foovalue" ); |
105
|
|
|
|
|
|
|
my $val = $r->pnotes( 'foo' ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 args( [$new_args] ) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Sets or gets the querystring for the request. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Example: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $str = $r->args(); |
114
|
|
|
|
|
|
|
$r->args( 'foo=bar&baz=bux' ); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 uri( [$new_uri] ) |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Sets or gets the URI for the current request: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Example: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $uri = $r->uri; |
123
|
|
|
|
|
|
|
$r->uri( '/path/to/page.asp' ); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 document_root( ) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Gets the document root for the server. This is the same as $config->web->www_root. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $root = $r->document_root; # /var/www/mysite.com/htdocs |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 method( ) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Gets the request method for the current request. Eg: C or C. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
if( $r->method eq 'GET' ) { |
136
|
|
|
|
|
|
|
# It's a "GET" request: |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
elsif( $r->method eq 'POST' ) { |
139
|
|
|
|
|
|
|
# It's a "POST" request: |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 pool( ) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns the current L object. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my $pool = $r->pool; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 connection( ) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Returns the current L object. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $connection = $r->connection; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 headers_out( ) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns a hashref representing the outgoing headers. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 err_headers_out( ) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Returns a hashref representing the outgoing headers. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 status( [$new_status] ) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Sets or gets the status code for the response. 200 for "OK", 301 for "Moved" - 404 for "not found" etc. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 content_type( [$new_content_type] ) |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Sets or gets the mime-header for the outgoing response. Default is C. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 print( $str ) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Adds C<$str> to the outgoing response buffer. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 rflush( ) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Does nothing. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|