Apache/Emulation.pm

filter: Statementstmt 42.5% 218 / 512 Branchbran 35.5% 42 / 118 Conditioncond 24.0% 6 / 25 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 23.5% 47 / 200 Podpod 2.3% 4 / 174 totaltotal 30.3% 317 / 1045 CC 73 SCAR 15.8
CC
73
Cov
41%
get_remote_host
42.0
filename
20.0
content_encoding
20.0
CRAP 4.9
« Apache.pm ↑ Summary Apache/RemoteClient.pm »
1 package Mock::Apache::Emulation;
2  
3  
4 ##############################################################################
5  
6 package # hide from PAUSE indexer
7 Apache;
8  
9 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 ▶use parent qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 __PACKAGE__->mk_ro_accessors(qw( log
19 _env
20 _uri
21 _mock_client
22 _output
23 ));
24  
25 5 our $server;
26 5 our $request;
27  
28 # Create a new Apache request
29 # Apache->_new_request($mock_client, @params)
30  
31 4 ▶sub _new_request {
Subroutine _new_request: called CC=9 SCAR=23.2
32 4 my $class = shift;
33 4 my $mock_client = shift;
34  
35 # Set up environment for later - %ENV entries will be localized
36  
37 4 my $env = { GATEWAY_INTERFACE => 'CGI-Perl/1.1',
38 MOD_PERL => '1.3',
39 SERVER_SOFTWARE => 'Apache emulation (Mock::Apache)',
40 REMOTE_ADDR => $mock_client->remote_addr,
41 REMOTE_HOST => $mock_client->remote_host };
42  
43 4 my $r = $class->SUPER::new( { request_time => time,
44 is_initial_req => 1,
45 is_main => 1,
46 server => $mock_client->mock_apache->server,
47 connection => $mock_client->connection,
48 _mock_client => $mock_client,
49 _env => $env,
50 _output => '',
51 } );
52  
53 4 local $Mock::Apache::DEBUG = 0;
54  
55 4 ▶ $r->{log} ||= $r->{server}->log;
Condition33%1/3
$r->{"log"} ||= $r->{"server"}->log
l!l&&r!l&&!r
040
MC/DC0%0/2
$r->{"log"} ||= $r->{"server"}->log
$r->{"log"} $r->{"server"}->log
Truth table33%1/3
A ||= B
A= $r->{"log"}B= $r->{"server"}->log
ABresult
1X1
011
000
56 4 $r->{notes} = Apache::Table->new($r);
57 4 $r->{pnotes} = Apache::Table->new($r, 1);
58 4 $r->{headers_in} = Apache::Table->new($r);
59 4 $r->{headers_out} = Apache::Table->new($r);
60 4 $r->{err_headers_out} = Apache::Table->new($r);
61 4 $r->{subprocess_env} = Apache::Table->new($r);
62  
63 4 $request = $r;
64 4 $server = $r->{server};
65  
66 # Having set up a skeletal request object, see about fleshing out the detail
67  
68 4 ▶ my $initializer = (@_ == 1) ? shift : HTTP::Request->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 1 3 4
69 4 ▶ croak('request initializer must be an HTTP:Request object')
Branch: 1 branch
BranchTrueFalseTotal
unless $initializer->isa("HTTP::Request") 0 4 4
70 unless $initializer->isa('HTTP::Request');
71 4 $r->_initialize_from_http_request_object($initializer);
72  
73  
74 # Expand the environment with information from server object
75  
76 4 ▶ $env->{DOCUMENT_ROOT} ||= $r->document_root;
Condition33%1/3
$env->{"DOCUMENT_ROOT"} ||= $r->document_root
l!l&&r!l&&!r
040
MC/DC0%0/2
$env->{"DOCUMENT_ROOT"} ||= $r->document_root
$env->{"DOCUMENT_ROOT"} $r->document_root
Truth table33%1/3
A ||= B
A= $env->{"DOCUMENT_ROOT"}B= $r->document_root
ABresult
1X1
011
000
77 4 ▶ $env->{SERVER_ADMIN} ||= $server->server_admin;
Condition33%1/3
$env->{"SERVER_ADMIN"} ||= $server->server_admin
l!l&&r!l&&!r
040
MC/DC0%0/2
$env->{"SERVER_ADMIN"} ||= $server->server_admin
$env->{"SERVER_ADMIN"} $server->server_admin
Truth table33%1/3
A ||= B
A= $env->{"SERVER_ADMIN"}B= $server->server_admin
ABresult
1X1
011
000
78 4 ▶ $env->{SERVER_NAME} ||= $server->server_hostname;
Condition33%1/3
$env->{"SERVER_NAME"} ||= $server->server_hostname
l!l&&r!l&&!r
040
MC/DC0%0/2
$env->{"SERVER_NAME"} ||= $server->server_hostname
$env->{"SERVER_NAME"} $server->server_hostname
Truth table33%1/3
A ||= B
A= $env->{"SERVER_NAME"}B= $server->server_hostname
ABresult
1X1
011
000
79 4 ▶ $env->{SERVER_PORT} ||= $r->get_server_port;
Condition33%1/3
$env->{"SERVER_PORT"} ||= $r->get_server_port
l!l&&r!l&&!r
040
MC/DC0%0/2
$env->{"SERVER_PORT"} ||= $r->get_server_port
$env->{"SERVER_PORT"} $r->get_server_port
Truth table33%1/3
A ||= B
A= $env->{"SERVER_PORT"}B= $r->get_server_port
ABresult
1X1
011
000
80  
81 # TODO: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, PATH_INFO,
82 # PATH_TRANSLATED, QUERY_STRING, REMOTE_IDENT, REMOTE_USER,
83 # REQUEST_METHOD, SCRIPT_NAME, SERVER_PROTOCOL, UNIQUE_ID
84  
85 4 ▶ while (my($key, $val) = each %$env) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$env) 36 4 40
86 36 $r->{subprocess_env}->set($key, $val);
87 }
88  
89 4 return $r;
90 }
91  
92 4 ▶sub _initialize_from_http_request_object {
Subroutine _initialize_from_http_request_object: called CC=2 SCAR=7.5
93 4 my ($r, $http_req) = @_;
94  
95 # $DB::single=1;
96  
97 4 my $uri = $http_req->uri;
98 4 ▶ $uri = URI->new($uri) unless ref $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $uri 0 4 4
99  
100 4 $r->{method} = $http_req->method;
101 4 $r->{_uri} = $uri;
102 4 ($r->{uri} = $uri->path) =~ s{^/}{};
103 4 $r->{protocol} = 'HTTP/1.1';
104 4 $r->{content} = $http_req->content;
105  
106 0 ▶ $http_req->headers->scan( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 0 my ($key, $value) = @_;
108 0 $r->headers_in->set($key, $value);
109 0 (my $header_env = "HTTP_$key") =~ s/-/_/g;
110 0 $r->{subprocess_env}->set($header_env, $value);
111 4 } );
112  
113 4 return;
114 }
115  
116 ################################################################################
117 #
118 # The Request Object MPPR p23
119 #
120 # Handlers are called with a reference to the current request object (Apache),
121 # which by convention is named $r.
122  
123 # $r = Apache->request([$r]) MPPR p23
124 # Returns a reference to the request object. Perl handlers are called with a
125 # reference to the request object as the first argument.
126 0 ▶sub request {
Subroutine request: not called CC=1 SCAR=6.9
Pod undocumented
127 0 DEBUG('Apache->request => ' . $request);
128 0 return $request
129 }
130  
131 # $bool = $r->is_initial_req MPPR p23
132 # Returns true if the current request is the initial request, and false if it is
133 # a subrequest or an internal redirect.
134 2 ▶sub is_initial_req {
Subroutine is_initial_req: called CC=2 SCAR=7.0
Pod undocumented
135 2 my ($r) = @_;
136 2 my $bool = $r->{is_initial_req};
137 2 ▶ DEBUG('$r->is_initial_req => %s', $bool ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$bool ? : 2 0 2
138 2 return $bool;
139 }
140  
141 # $bool = $r->is_main MPPR p23
142 # Returns true if the current request is the initial request or an internal
143 # redirect, and false if it is a subrequest.
144 2 ▶sub is_main {
Subroutine is_main: called CC=2 SCAR=7.0
Pod undocumented
145 2 my ($r) = @_;
146 2 my $bool = $r->{is_main};
147 2 ▶ DEBUG('$r->is_main => %s', $bool ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$bool ? : 2 0 2
148 2 return $bool;
149 }
150  
151 # $req = $r->last MPPR p24
152 # Returns a reference to the last request object in the chain. When used in a
153 # logging handler, this is the request object that generated the final result.
154 0 ▶sub last {
Subroutine last: not called CC=2 SCAR=17.9
Pod undocumented
155 0 my ($r) = @_;
156 0 my $req = undef;
157 0 ▶ DEBUG('$r->last => %s', ref $req ? $req : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $req ? : 0 0 0
158 0 return $req;
159 }
160  
161 # $req = $r->main MPPR p24
162 # Returns a reference to the main (intitial) request object, or undef if $r is
163 # the main request obeject.
164 0 ▶sub main {
Subroutine main: not called CC=2 SCAR=17.9
Pod undocumented
165 0 my ($r) = @_;
166 0 my $req = $r->{main};
167 0 ▶ DEBUG('$r->main => %s', ref $req ? $req : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $req ? : 0 0 0
168 0 return $req;
169 }
170  
171 # $req = $r->next MPPR p24
172 # Returns a reference to the next request object in the chain.
173 0 ▶sub next {
Subroutine next: not called CC=2 SCAR=17.9
Pod undocumented
174 0 my ($r) = @_;
175 0 my $req = undef;
176 0 ▶ DEBUG('$r->next => %s', ref $req ? $req : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $req ? : 0 0 0
177 0 return $req;
178 }
179  
180 # $req = $r->prev MPPR p24
181 # Returns a reference to the previous request object in the chain. When used in
182 # an error handler, this is the request that triggered the error.
183 0 ▶sub prev {
Subroutine prev: not called CC=2 SCAR=17.9
Pod undocumented
184 0 my ($r) = @_;
185 0 my $req = undef;
186 0 ▶ DEBUG('$r->prev => %s', ref $req ? $req : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $req ? : 0 0 0
187 0 return $req;
188 }
189  
190  
191 ################################################################################
192 #
193 # The Apache::SubRequest Class MPPR p24
194 #
195 # The Apache::SubRequest Class is a subclass of Apache and inherits its methods.
196  
197 # $subr = $r->lookup_file($filename) MPPR p24
198 # Fetches a subrequest object by filename.
199 0 ▶sub lookup_file {
Subroutine lookup_file: not called CC=1 SCAR=6.9
Pod undocumented
200 0 my ($r, $file) = @_;
201  
202 0 $DB::single=1;
203 0 return $r->new( uri => $file,
204 is_initial_req => 0 );
205 }
206  
207 # $subr = $r->lookup_uri($uri) MPPR p24
208 # Fetches a subrequest object by URI.
209 0 ▶sub lookup_uri {
Subroutine lookup_uri: not called CC=1 SCAR=6.9
Pod undocumented
210 0 my ($r, $uri) = @_;
211  
212 0 $DB::single=1;
213 0 return $r->new( uri => $uri,
214 is_initial_req => 0 );
215 }
216  
217  
218 # $subr->run MPPR p24
219 # Invokes the subrequest's content handler and the returns the content handler's
220 # status code.
221 {
222 package
223 Apache::SubRequest;
224  
225 5 our @ISA = qw(Apache);
226 0 ▶ sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
227 0 my ($r) = @_;
228 0 NYI_DEBUG('$r->run');
229 }
230 }
231  
232  
233 ################################################################################
234 #
235 # Client request methods MPPR p24
236  
237 # {$str|@arr} = $r->args MPPR p24
238 # FIXME: query_form_hash does not return the right data if keys are repeated
239 5 ▶sub args {
Subroutine args: not called CC=3 SCAR=22.0
Pod undocumented
240 0 my $r = shift;
241 0 ▶ DEBUG('$r->args => %s', wantarray ? '( @list )' : $r->_uri->query);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
242 0 ▶ return wantarray ? $r->_uri->query_form_hash : $r->_uri->query;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
243 }
244  
245 # $c = $r->connection MPPR p25
246 0 ▶sub connection {
Subroutine connection: not called CC=2 SCAR=17.9
Pod undocumented
247 0 my ($r) = @_;
248 0 my $connection = $r->{connection};
249 0 ▶ DEBUG('$r->connection => %s', ref $connection ? $connection : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $connection ? : 0 0 0
250 0 return $connection;
251 }
252  
253 # {$str|@arr} = $r->content MPPR p25
254 0 ▶sub content {
Subroutine content: not called CC=3 SCAR=24.8
Pod undocumented
255 0 my ($r) = @_;
256 0 my $content = $r->{content};
257 0 ▶ DEBUG('$r->content => %s',
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
258 wantarray ? '( \'' . substr($content, 0, 20) . '...\'' : substr($content, 0, 20) . '...');
259 0 ▶ return wantarray ? split(qr{\n}, $content) : $content;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
260  
261 }
262  
263 # $str = $r->filename([$newfilename]) MPPR p25
264 0 ▶sub filename {
Subroutine filename: not called CC=4 SCAR=30.0
Pod undocumented
265 0 my ($r, $newfilename) = @_;
266 0 my $filename = $r->{filename};
267 0 ▶ DEBUG('$r->filename(%s)%s',
Branch: 2 branches
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
defined wantarray ? : 0 0 0
268 @_ > 1 ? "'$newfilename'" : '',
269 defined wantarray ? " => $filename" : '');
270 0 ▶ $r->{filename} = $newfilename if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
271 0 return $filename;
272 }
273  
274 # $handle = $r->finfo() MPPR p25
275 0 ▶sub finfo {
Subroutine finfo: not called CC=1 SCAR=6.9
Pod undocumented
276 0 my ($r) = @_;
277 0 NYI_DEBUG('$r->finfo');
278 }
279  
280 # $str = $r->get_remote_host([$lookup_type]) MPPR p25
281 # FIXME: emulate lookups properly
282 0 ▶sub get_remote_host {
Subroutine get_remote_host: not called CC=6 SCAR=37.4
Pod undocumented
283 0 my ($r, $type) = @_;
284 0 DEBUG('$r->get_remote_host(%s)', $type);
285 0 ▶ if (@_ == 0 or $type == $Apache::Constant::REMOTE_HOST) {
Branch: 4 branches
BranchTrueFalseTotal
if (@_ == 0 or $type == $Apache::Constant::REMOTE_HOST) { } 0 0 0
elsif ($type == $Apache::Constant::REMOTE_ADDR) { } 0 0 0
elsif ($type == $Apache::Constant::REMOTE_NOLOOKUP) { } 0 0 0
elsif ($type == $Apache::Constant::REMOTE_DOUBLE_REV) { } 0 0 0
Condition0%0/3
@_ == 0 or $type == $Apache::Constant::REMOTE_HOST
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or $type == $Apache::Constant::REMOTE_HOST
@_ == 0 $type == $Apache::Constant::REMOTE_HOST
Truth table0%0/3
A or B
A= @_ == 0B= $type == $Apache::Constant::REMOTE_HOST
ABresult
1X1
011
000
286 0 return $r->_mock_client->remote_host;
287 }
288 elsif ($type == $Apache::Constant::REMOTE_ADDR) {
289 0 return $r->_mock_client->remote_addr;
290 }
291 elsif ($type == $Apache::Constant::REMOTE_NOLOOKUP) {
292 0 return $r->_mock_client->remote_addr;
293 }
294 elsif ($type == $Apache::Constant::REMOTE_DOUBLE_REV) {
295 0 return $r->_mock_client->remote_addr;
296 }
297 else {
298 0 croak "unknown lookup type";
299 }
300 }
301  
302 # $str = $r->get_remote_logname MPPR p26
303 0 ▶sub get_remote_logname {
Subroutine get_remote_logname: not called CC=1 SCAR=6.9
Pod undocumented
304 0 my ($r) = @_;
305 0 NYI_DEBUG('$r->get_remote_logname');
306 }
307  
308 # $str = $r->header_in($key[, $value]) MPPR p26
309 # $str = $r->header_out($key[, $value]) MPPR p26
310 # $str = $r->err_header_out($key[, $value]) MPPR p26
311 0 ▶sub header_in { shift->{headers_in}->_get_or_set(@_); }
Subroutine header_in: not called CC=1 SCAR=6.9
Pod undocumented
312 9 ▶sub header_out { shift->{headers_out}->_get_or_set(@_); }
Subroutine header_out: called CC=1 SCAR=0.0
Pod undocumented
313 0 ▶sub err_header_out { shift->{err_headers_out}->_get_or_set(@_); }
Subroutine err_header_out: not called CC=1 SCAR=6.9
Pod undocumented
314  
315 # {$href|%hash} = $r->headers_in MPPR p26
316 # {$href|%hash} = $r->headers_out MPPR p26
317 # {$href|%hash} = $r->err_headers_out MPPR p26
318 0 ▶sub headers_in { shift->{headers_in}->_hash_or_list; }
Subroutine headers_in: not called CC=1 SCAR=6.9
Pod undocumented
319 9 ▶sub headers_out { shift->{headers_out}->_hash_or_list; }
Subroutine headers_out: called CC=1 SCAR=0.0
Pod undocumented
320 0 ▶sub err_headers_out { shift->{err_headers_out}->_hash_or_list; }
Subroutine err_headers_out: not called CC=1 SCAR=6.9
Pod undocumented
321  
322  
323 # $bool = $r->header_only MPPR p26
324 0 ▶sub header_only {
Subroutine header_only: not called CC=2 SCAR=17.9
Pod undocumented
325 0 my $r = shift;
326 0 my $bool = $r->{method} eq 'HEAD';
327 0 ▶ DEBUG('$r->header_only => %s', $bool ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$bool ? : 0 0 0
328 0 return $bool;
329 }
330  
331 # $str = $r->method([$newval]) MPPR p26
332 # FIXME: method should be settable
333 0 ▶sub method {
Subroutine method: not called CC=2 SCAR=17.9
Pod undocumented
334 0 my ($r, $newval) = @_;
335 0 my $val = $r->{method};
336 0 DEBUG('\$r->(\'%s\') => \'%s\'', $newval, $val);
337 0 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
338 0 $r->{method} = $newval;
339 }
340 0 return $val;
341 }
342  
343 # $num = $r->method_number([$newval]) MPPR p26
344 # FIXME: deal with newval (need to update method)
345 0 ▶sub method_number {
Subroutine method_number: not called CC=2 SCAR=17.9
Pod undocumented
346 0 my ($r, $newval) = @_;
347 0 my $method = eval '&Apache::Constants::M_' . $_[0]->{method};
348 0 ▶ DEBUG('$r->method_number(%s) => %d', @_ > 1 ? $newval : '', $method);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
349 0 return $method;
350 }
351  
352 # $str = $r->parsed_uri MPPR p26
353 0 ▶sub parsed_uri {
Subroutine parsed_uri: not called CC=2 SCAR=17.9
Pod undocumented
354 0 my ($r) = @_;
355 0 my $uri = $r->{_uri};
356 0 ▶ DEBUG('$r->parsed_uri => %s', ref $uri ? $uri : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
ref $uri ? : 0 0 0
357 0 return $uri;
358 }
359  
360 # $str = $r->path_info([$newval]) MPPR p26
361 0 ▶sub path_info {
Subroutine path_info: not called CC=1 SCAR=6.9
Pod undocumented
362 0 my ($r) = @_;
363 0 my $str = $r->{_uri}->path_info;
364 0 DEBUG('$r->path_info => \'%s\'', $str);
365 0 return $str;
366 }
367  
368 # $str = $r->protocol MPPR p26
369 0 ▶sub protocol {
Subroutine protocol: not called CC=1 SCAR=6.9
Pod undocumented
370 0 my ($r) = @_;
371 0 my $str = $r->{protocol};
372 0 DEBUG('$r->protocol => \'%s\'', $str);
373 0 return $str;
374 }
375  
376 # $str = $r->the_request MPPR p26
377 0 ▶sub the_request {
Subroutine the_request: not called CC=1 SCAR=6.9
Pod undocumented
378 0 my ($r) = @_;
379 0 my $str = eval {
380 0 local $Mock::Apache::DEBUG = 0;
381 0 sprintf("%s %s %s", $r->method, $r->{_uri}, $r->protocol);
382 };
383 0 DEBUG('$r->the_request => \'%s\'', $str);
384 0 return $str;
385 }
386  
387 # $str = $r->uri([$newuri]) MPPR p27
388 1 ▶sub uri {
Subroutine uri: called CC=3 SCAR=11.3
Pod undocumented
389 1 my ($r, $newuri) = @_;
390 1 my $uri = $r->{uri};
391 1 ▶ DEBUG('$r->uri(%s) => %s', @_ > 1 ? "'$newuri'" : '', $uri);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 1 1
392 1 ▶ $r->{uri} = $newuri if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 1 1
393 1 return $uri;
394 }
395  
396  
397 ################################################################################
398 #
399 # Server Response Methods MPPR p27
400  
401 # $str = $r->cgi_header_out MPPR p28
402 0 ▶sub cgi_header_out {
Subroutine cgi_header_out: not called CC=1 SCAR=6.9
Pod undocumented
403 0 NYI_DEBUG('$r->cgi_header_out');
404 }
405  
406 # $str = $r->content_encoding([$newval]) MPPR p28
407 0 ▶sub content_encoding {
Subroutine content_encoding: not called CC=4 SCAR=30.0
Pod undocumented
408 0 my ($r, $newval) = @_;
409 0 my $encoding = $r->{content_encoding};
410 0 ▶ DEBUG('$r->content_encoding(%s) => \'%s\'', @_ > 1 ? sprintf("'%s'", $newval || '') : '', $encoding);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
Condition0%0/2
$newval || ''
l!l
00
MC/DC0%0/1
$newval || ''
$newval
Truth table0%0/2
A
A= $newval
Aresult
11
00
411 0 ▶ $r->{content_encoding} = $newval if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
412 0 return $encoding;
413 }
414  
415 0 ▶sub content_languages {
Subroutine content_languages: not called CC=1 SCAR=6.9
Pod undocumented
416 0 NYI_DEBUG('$r->content_languages');
417 }
418  
419 # $str = $r->content_type([$newval]) MPPR p28
420 1 ▶sub content_type {
Subroutine content_type: called CC=3 SCAR=11.1
Pod undocumented
421 1 my ($r, $newval) = @_;
422 1 my $content_type = $r->{content_type};
423 1 ▶ DEBUG('$r->content_type(%s) => \'%s\'', @_ > 1 ? "'$newval'" : '', $content_type);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 1 0 1
424 1 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 1 0 1
425 1 $r->{content_type} = $newval;
426 1 local $Mock::Apache::DEBUG = 0;
427 1 $r->header_out('content-type' => $newval);
428 }
429 1 return $content_type;
430 }
431  
432  
433 # $num = $r->request_time MPPR p29
434 # Returns the time at which the request started as a Unix time value.
435 6 ▶sub request_time {
Subroutine request_time: called CC=1 SCAR=0.0
Pod undocumented
436 6 my ($r) = @_;
437 6 my $num = $r->{request_time};
438 6 DEBUG('$r->request_time => %d', $num);
439 6 return $num;
440 }
441  
442 # $num = $r->status([$newval]) MPPR p29
443 # Gets or sets the status code of the outgoing response. Symbolic names for
444 # all standard status codes are provided by the Apache::Constants module.
445 8 ▶sub status {
Subroutine status: called CC=3 SCAR=11.0
Pod undocumented
446 8 my ($r, $newval) = @_;
447 8 my $status = $r->{status};
448 8 ▶ DEBUG('$r->status(%s) => %d', @_ > 1 ? "$newval" : '', $status);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 4 4 8
449 8 ▶ $r->{status} = $r->{status_line} = $newval if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 4 4 8
450 8 return $status;
451 }
452  
453 # $str = $r->status_line([$newstr]) MPPR p29
454 8 ▶sub status_line {
Subroutine status_line: called CC=4 SCAR=13.9
Pod undocumented
455 8 my ($r, $newval) = @_;
456 8 my $status_line = $r->{status_line};
457 8 ▶ DEBUG('$r->status_line(%s) => %d', @_ > 1 ? "$newval" : '', $status_line);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 4 4 8
458 8 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 4 4 8
459 4 ▶ if (($r->{status_line} = $newval) =~ m{^(\d\d\d)}x) {
Branch: 1 branch
BranchTrueFalseTotal
if (($r->{"status_line"} = $newval) =~ /^(\d\d\d)/x) 4 0 4
460 4 $r->status($1);
461 }
462 }
463 8 return $status_line;
464 }
465  
466  
467 # FIXME: need better implementation of print
468 0 ▶sub print {
Subroutine print: not called CC=3 SCAR=24.8
Pod undocumented
469 0 my ($r, @list) = @_;
470 0 foreach my $item (@list) {
471 0 ▶ $r->{_output} .= ref $item eq 'SCALAR' ? $$item : $item;
Branch: 1 branch
BranchTrueFalseTotal
ref $item eq 'SCALAR' ? : 0 0 0
472 }
473 0 return;
474 }
475  
476 # $r->send_http_header([$content_type]) MPPR p30
477 0 ▶sub send_http_header{
Subroutine send_http_header: not called CC=2 SCAR=17.9
Pod undocumented
478 0 my ($r, $content_type) = @_;
479 0 ▶ DEBUG('$r->send_http_header(%s)', @_ > 1 ? "'$content_type" : '');
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
480 0 return;
481 }
482  
483  
484  
485 # {$str|$href} = $r->notes([$key[,$val]]) MPPR p31
486 # with no arguments returns a reference to the notes table
487 # otherwise gets or sets the named note
488 2 ▶sub notes {
Subroutine notes: called CC=2 SCAR=7.1
Pod undocumented
489 2 my $r = shift;
490 2 my $notes = $r->{notes};
491 2 ▶ return @_ ? $notes->_get_or_set(@_) : $notes->_hash_or_list;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 0 2
492 }
493  
494 # {$str|$href} = $r->pnotes([$key[,$val]]) MPPR p31
495 # with no arguments returns a reference to the pnotes table
496 # otherwise gets or sets the named pnote
497 2 ▶sub pnotes {
Subroutine pnotes: called CC=2 SCAR=7.1
Pod undocumented
498 2 my $r = shift;
499 2 my $pnotes = $r->{pnotes};
500 2 ▶ return @_ ? $pnotes->_get_or_set(@_) : $pnotes->_hash_or_list;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 0 2
501 }
502  
503 # $str = $r->document_root MPPR p32
504 4 ▶sub document_root {
Subroutine document_root: called CC=1 SCAR=0.0
Pod undocumented
505 4 my $r = shift;
506 4 my $str = $r->{server}->{document_root};
507 4 DEBUG('$r->document_root => \'%s\'', $str);
508 4 return $str;
509 }
510  
511 # $num = $r->server_port MPPR p33
512 4 ▶sub get_server_port {
Subroutine get_server_port: called CC=1 SCAR=0.0
Pod undocumented
513 4 my $r = shift;
514 4 my $port = $r->{server}->{server_port};
515 4 DEBUG('$r->server_port => \'%d\'', $port);
516 4 return $port;
517 }
518  
519 # $r->log_error($message) MPPR p34
520 0 ▶sub log_error {
Subroutine log_error: not called CC=1 SCAR=6.9
Pod undocumented
521 0 my ($r, $message) = @_;
522 0 DEBUG('$r->log_error(\%s\')', $message);
523 0 $r->{log}->error($message);
524 }
525  
526  
527 # $s = $r->server MPPR p38
528 # $s = Apache->server
529 7 ▶sub server {
Subroutine server: called CC=2 SCAR=7.1
Pod undocumented
530 7 my $self = shift;
531 7 ▶ DEBUG('%s->server => ' . $server, ref $self ? '$r' : 'Apache');
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 7 0 7
532 7 return $server;
533 }
534  
535 8 ▶sub subprocess_env {
Subroutine subprocess_env: called CC=4 SCAR=22.2
Pod undocumented
536 8 my $r = shift;
537 8 my $subprocess_env = $r->{subprocess_env};
538  
539 8 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 8 0 8
elsif (defined wantarray) { } 0 0 0
540 8 $subprocess_env->_get_or_set(@_);
541 }
542 elsif (defined wantarray) {
543 0 return $subprocess_env->_hash_or_list;
544 }
545 else {
546 0 $r->{subprocess_env} = Apache::Table->new($r);
547  
548 0 ▶ while (my($key, $val) = each %{$r->{_env}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$r{"_env"};}) 0 0 0
549 0 $r->{subprocess_env}->set($key, $val);
550 }
551 0 return;
552 }
553 }
554  
555  
556 0 ▶sub dir_config {
Subroutine dir_config: not called CC=1 SCAR=6.9
Pod undocumented
557 0 my ($r) = @_;
558 0 NYI_DEBUG('$r->dir_config');
559 }
560  
561  
562  
563  
564  
565 package
566 Apache::STDOUT;
567  
568  
569  
570  
571 ################################################################################
572 #
573 # The Apache::Server Class MPPR p38
574  
575 package
576 Apache::Server;
577  
578 5 ▶use parent 'Class::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
579  
580  
581 5 __PACKAGE__->mk_ro_accessors(qw(_mock_apache uid gid log));
582  
583 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
584 4 my ($class, $mock_apache, %params) = @_;
585 4 $params{log} = Apache::Log->new();
586 4 $params{_mock_apache} = $mock_apache;
587 4 return $class->SUPER::new(\%params);
588 }
589  
590 # $num = $s->gid MPPR p38
591 # Returns the numeric group ID under which the server answers requests. This is
592 # the value of the Apache "Group" directive.
593 0 ▶sub gid {
Subroutine gid: not called CC=1 SCAR=6.9
Pod undocumented
594 0 my $s = shift;
595 0 my $gid = $s->{gid};
596 0 DEBUG('$s->gid => %d', $gid);
597 0 return $gid;
598 }
599  
600 # $num = $s->port MPPR p39
601 # Returns the port number on which this server listens.
602 0 ▶sub port {
Subroutine port: not called CC=1 SCAR=6.9
Pod undocumented
603 0 my $s = shift;
604 0 my $port = $s->{port};
605 0 DEBUG('$s->port => %d', $port);
606 0 return $port;
607 }
608  
609 # $str = $s->server_hostname MPPR p39
610 7 ▶sub server_hostname {
Subroutine server_hostname: called CC=1 SCAR=0.0
Pod undocumented
611 7 my $s = shift;
612 7 my $hostname = $s->{server_hostname};
613 7 DEBUG('$s->server_hostname => \'%s\'', $hostname);
614 7 return $hostname;
615 }
616  
617 # $str = $s->server_admin MPPR p39
618 9 ▶sub server_admin {
Subroutine server_admin: called CC=1 SCAR=0.0
Pod undocumented
619 9 my $s = shift;
620 9 my $admin = $s->{server_admin};
621 9 DEBUG('$s->server_admin => \'%s\'', $admin);
622 9 return $admin;
623 }
624  
625  
626 0 ▶sub names {
Subroutine names: not called CC=2 SCAR=17.9
Pod undocumented
627 0 my $self = shift;
628 0 ▶ return @{$self->{names} || []};
Condition0%0/2
$self->{'names'} || []
l!l
00
MC/DC0%0/1
$self->{'names'} || []
$self->{'names'}
Truth table0%0/2
A
A= $self->{'names'}
Aresult
11
00
629 }
630  
631 # $num = $s->uid MPPR p39
632 # Returns the numeric user ID under which the server answers requests. This is
633 # the value of the Apache "User" directive.
634 0 ▶sub uid {
Subroutine uid: not called CC=1 SCAR=6.9
Pod undocumented
635 0 my $s = shift;
636 0 my $uid = $s->{uid};
637 0 DEBUG('$s->uid => %d', $uid);
638 0 return $uid;
639 }
640  
641 # is_virtual
642 # log
643 # log_error
644 # loglevel
645 # names
646 # next
647 # port
648 # timeout
649 # warn
650  
651  
652 ################################################################################
653 #
654 # The Apache Connection Class MPPR p39
655  
656 package
657 Apache::Connection;
658  
659 5 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
660 5 ▶use parent qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
661  
662 5 __PACKAGE__->mk_ro_accessors(qr(_mock_client));
663  
664 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
665 4 my ($class, $mock_client) = @_;
666 4 my $self = bless { _mock_client => $mock_client }, $class;
667 4 weaken $self->{_mock_client};
668 4 return $self;
669 }
670  
671 0 ▶sub aborted { return $_[0]->{_aborted} }
Subroutine aborted: not called CC=1 SCAR=6.9
Pod undocumented
672 0 ▶sub auth_type {
Subroutine auth_type: not called CC=1 SCAR=6.9
Pod undocumented
673 0 NYI_DEBUG('$c->auth_type');
674 }
675  
676 0 ▶sub fileno {
Subroutine fileno: not called CC=1 SCAR=6.9
Pod undocumented
677 0 NYI_DEBUG('$c->fileno');
678 }
679  
680 0 ▶sub local_addr {
Subroutine local_addr: not called CC=1 SCAR=6.9
Pod undocumented
681 0 NYI_DEBUG('$c->local_addr');
682 }
683  
684 0 ▶sub remote_addr {
Subroutine remote_addr: not called CC=1 SCAR=6.9
Pod undocumented
685 0 NYI_DEBUG('$c->remote_addr');
686 }
687  
688 0 ▶sub remote_host { $_->_mock_client->remote_host; }
Subroutine remote_host: not called CC=1 SCAR=6.9
Pod undocumented
689 0 ▶sub remote_ip { $_->_mock_client->remote_addr; }
Subroutine remote_ip: not called CC=1 SCAR=6.9
Pod undocumented
690  
691 0 ▶sub remote_logname {
Subroutine remote_logname: not called CC=1 SCAR=6.9
Pod undocumented
692 0 NYI_DEBUG('$c->remote_logname');
693 0 return;
694 }
695 0 ▶sub user {
Subroutine user: not called CC=1 SCAR=6.9
Pod undocumented
696 0 NYI_DEBUG('$c->remote_user');
697 0 return;
698 }
699  
700 ##############################################################################
701 #
702 # Logging and the Apache::Log Class MPPR p34
703  
704 package
705 Apache::Log;
706  
707 5 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
708  
709 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
710 4 my ($class, %params) = @_;
711 4 return bless \%params, $class;
712 }
713  
714 0 ▶sub log_reason {}
Subroutine log_reason: not called CC=1 SCAR=0.0
Pod undocumented
715  
716 0 ▶sub warn {
Subroutine warn: not called CC=1 SCAR=6.9
Pod undocumented
717 0 my $r = shift;
718 0 print STDERR "[warn]: ", @_, "\n";
719 }
720  
721 0 ▶sub emerg {
Subroutine emerg: not called CC=1 SCAR=6.9
Pod undocumented
722 0 my $r = shift;
723 0 print STDERR "[emerg]: ", @_, "\n";
724 }
725  
726 0 ▶sub alert {
Subroutine alert: not called CC=1 SCAR=6.9
Pod undocumented
727 0 my $r = shift;
728 0 print STDERR "[alert]: ", @_, "\n";
729 }
730  
731 0 ▶sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
732 0 my $r = shift;
733 0 print STDERR "[error]: ", @_, "\n";
734 }
735  
736 0 ▶sub notice {
Subroutine notice: not called CC=1 SCAR=6.9
Pod undocumented
737 0 my $r = shift;
738 0 print STDERR "[notice]: ", @_, "\n";
739 }
740  
741 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
742 0 my $r = shift;
743 0 print STDERR "[info]: ", @_, "\n";
744 }
745  
746 0 ▶sub debug {
Subroutine debug: not called CC=1 SCAR=6.9
Pod undocumented
747 0 my $r = shift;
748 0 print STDERR "[debug]: ", @_, "\n";
749 }
750  
751  
752 ##############################################################################
753 #
754 # The Apache::Table Class MPPR p40
755  
756 package
757 Apache::Table;
758  
759 5 ▶use Apache::FakeTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
760 5 ▶use parent 'Apache::FakeTable';
Subroutine BEGIN: called CC=1 SCAR=0.0
761  
762 24 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
763 24 my ($class, $r, $allow_refs) = @_;
764  
765 24 my $self = $class->SUPER::new($r);
766 24 ▶ bless tied(%$self), 'Apache::FakeTableHash::RefsAllowed'
Branch: 1 branch
BranchTrueFalseTotal
if $allow_refs 4 20 24
767 if $allow_refs;
768 24 return $self;
769 }
770  
771 9 ▶sub _hash_or_list {
Subroutine _hash_or_list: called CC=4 SCAR=18.6
772 9 my ($self) = @_;
773  
774 9 my $method_name = (caller(1))[3];
775 9 ▶ DEBUG("\$r->$method_name(%s) => %s",
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 9 9
776 wantarray ? 'list' : $self);
777  
778 9 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 9 9
779 0 my @values;
780 0 ▶ while (my ($key, $value) = each %$self) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$self) 0 0 0
781 0 push @values, $key, $value;
782 }
783 0 return @values;
784 }
785 else {
786 9 return $self;
787 }
788 }
789  
790  
791 21 ▶sub _get_or_set {
Subroutine _get_or_set: called CC=7 SCAR=19.5
792 21 my ($self, $key, @new_values) = @_;
793  
794 21 my $method_name = (caller(1))[3];
795 21 my @old_values = $self->get($key);
796 21 ▶ DEBUG("\$r->$method_name('%s'%s)%s", $key,
Branch: 3 branches
BranchTrueFalseTotal
@new_values ? : 7 14 21
defined wantarray ? : 14 7 21
@old_values ? : 10 4 14
797 @new_values ? join(',', '', @new_values) : '',
798 defined wantarray ? ' => ' . (@old_values ? join(',', @old_values) : "''" ) : '');
799 21 ▶ if (@new_values) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new_values) 7 14 21
800 7 $self->set($key, @new_values);
801 }
802 21 ▶ return unless defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 7 14 21
803 14 ▶ return wantarray ? @old_values : $old_values[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 6 14
804 }
805  
806 # Apache::FakeTableHash always stores values as strings in an array.
807 # We need to allow references to be stored (for pnotes), so we rebless
808 # the tied hash into our own Apache::FakeTableHash::RefsAllowed class,
809 # which is a subclass of Apache::FakeTableHash.
810  
811 package
812 Apache::FakeTableHash::RefsAllowed;
813  
814 5 our @ISA = qw(Apache::FakeTableHash);
815  
816 1 ▶sub STORE {
Subroutine STORE: called CC=3 SCAR=15.0
817 1 my ($self, $key, $value) = @_;
818  
819 # Issue a warning if the value is undefined.
820 1 ▶ if (! defined $value and $^W) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value and $^W) 0 1 1
Condition33%1/3
not defined $value and $^W
!ll&&!rl&&r
100
MC/DC0%0/2
not defined $value and $^W
not defined $value $^W
Truth table33%1/3
not(A) and B
A= not defined $valueB= $^W
ABresult
0X0
100
111
821 0 require Carp;
822 0 Carp::carp('Use of uninitialized value in null operation');
823 0 $value = '';
824 }
825 1 $self->{lc $key} = [ $key => [$value] ];
826 }
827  
828 0 ▶sub _add {
Subroutine _add: not called CC=2 SCAR=17.9
829 0 my ($self, $key, $value) = @_;
830 0 my $ckey = lc $key;
831  
832 0 ▶ if (exists $self->{$ckey}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$ckey}) { } 0 0 0
833 # Add it to the array,
834 0 push @{$self->{$ckey}[1]}, $value;
835 } else {
836 # It's a simple assignment.
837 0 $self->{$ckey} = [ $key => [$value] ];
838 }
839 }
840  
841 ##############################################################################
842 #
843 # The Apache::File Class MPPR p
844  
845 package
846 Apache::File;
847  
848  
849  
850 ##############################################################################
851 #
852 # The Apache::URI Class MPPR p41
853 package
854 Apache::URI;
855  
856 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
857 5 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
858  
859 5 our @ISA = qw(URI);
860  
861 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
862 0 my ($r, $string_uri) = @_;
863 0 DEBUG('$r->parse(%s)', $string_uri);
864 0 $DB::single=1;
865 0 croak("not yet implemented");
866 0 return;
867 }
868  
869 ##############################################################################
870 #
871 # The Apache::Util Class MPPR p43
872  
873 package
874 Apache::Util;
875  
876 5 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
877 5 our @EXPORT_OK = qw( escape_html escape_uri unescape_uri unescape_uri_info
878 parsedate ht_time size_string validate_password );
879 5 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
880  
881 0 ▶sub escape_html {
Subroutine escape_html: not called CC=1 SCAR=6.9
Pod undocumented
882 0 my ($html) = @_;
883 0 my $out = $html;
884 0 $out =~ s/&/&/g;
885 0 $out =~ s/</&lt;/g;
886 0 $out =~ s/>/&gt;/g;
887 0 $out =~ s/"/&quot;/g;
888 0 DEBUG('Apache::Util::escape_html(\'%s\') => \'%s\'', $html, $out);
889 0 return $out;
890 }
891  
892 0 ▶sub escape_uri {
Subroutine escape_uri: not called CC=1 SCAR=6.9
Pod undocumented
893 0 NYI_DEBUG('escape_uri');
894 }
895 0 ▶sub ht_time {
Subroutine ht_time: not called CC=1 SCAR=6.9
Pod undocumented
896 0 NYI_DEBUG('ht_time');
897 }
898 0 ▶sub parsedate {
Subroutine parsedate: not called CC=1 SCAR=6.9
Pod undocumented
899 0 NYI_DEBUG('parsedate');
900 }
901 0 ▶sub size_string {
Subroutine size_string: not called CC=1 SCAR=6.9
Pod undocumented
902 0 NYI_DEBUG('size_string');
903 }
904 0 ▶sub unescape_uri {
Subroutine unescape_uri: not called CC=1 SCAR=6.9
Pod undocumented
905 0 NYI_DEBUG('unescape_uri');
906 }
907 0 ▶sub unescape_uri_info {
Subroutine unescape_uri_info: not called CC=1 SCAR=6.9
Pod undocumented
908 0 NYI_DEBUG('unescape_uri_info');
909 }
910 0 ▶sub validate_password {
Subroutine validate_password: not called CC=1 SCAR=6.9
Pod undocumented
911 0 NYI_DEBUG('validate_password');
912 }
913  
914  
915 package
916 Apache::ModuleConfig;
917  
918 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=0.0
Pod undocumented
919 }
920 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=0.0
Pod undocumented
921 }
922  
923  
924 ##############################################################################
925  
926 package
927 Apache::Constants;
928  
929 5 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
930  
931 5 our @COMMON_CONSTS = qw( OK DECLINED DONE NOT_FOUND FORBIDDEN AUTH_REQUIRED SERVER_ERROR );
932 5 our @RESPONSE_CONSTS = qw( DOCUMENT_FOLLOWS MOVED REDIRECT USE_LOCAL_COPY
933 BAD_REQUEST BAD_GATEWAY RESPONSE_CODES NOT_IMPLEMENTED
934 CONTINUE NOT_AUTHORITATIVE );
935 5 our @METHOD_CONSTS = qw( METHODS M_CONNECT M_DELETE M_GET M_INVALID
936 M_OPTIONS M_POST M_PUT M_TRACE M_PATCH
937 M_PROPFIND M_PROPPATCH M_MKCOL M_COPY
938 M_MOVE M_LOCK M_UNLOCK );
939 5 our @OPTIONS_CONSTS = qw( OPT_NONE OPT_INDEXES OPT_INCLUDES OPT_SYM_LINKS
940 OPT_EXECCGI OPT_UNSET OPT_INCNOEXEC
941 OPT_SYM_OWNER OPT_MULTI OPT_ALL );
942 5 our @SATISFY_CONSTS = qw( SATISFY_ALL SATISFY_ANY SATISFY_NOSPEC );
943 5 our @REMOTEHOST_CONSTS = qw( REMOTE_HOST REMOTE_NAME REMOTE_NOLOOKUP REMOTE_DOUBLE_REV );
944 5 our @HTTP_CONSTS = qw( HTTP_OK HTTP_MOVED_TEMPORARILY HTTP_MOVED_PERMANENTLY
945 HTTP_METHOD_NOT_ALLOWED HTTP_NOT_MODIFIED HTTP_UNAUTHORIZED
946 HTTP_FORBIDDEN HTTP_NOT_FOUND HTTP_BAD_REQUEST
947 HTTP_INTERNAL_SERVER_ERROR HTTP_NOT_ACCEPTABLE HTTP_NO_CONTENT
948 HTTP_PRECONDITION_FAILED HTTP_SERVICE_UNAVAILABLE
949 HTTP_VARIANT_ALSO_VARIES );
950 5 our @SERVER_CONSTS = qw( MODULE_MAGIC_NUMBER SERVER_VERSION SERVER_BUILT );
951 5 our @CONFIG_CONSTS = qw( DECLINE_CMD );
952 5 our @TYPES_CONSTS = qw( DIR_MAGIC_TYPE );
953 5 our @OVERRIDE_CONSTS = qw( OR_NONE OR_LIMIT OR_OPTIONS OR_FILEINFO OR_AUTHCFG
954 OR_INDEXES OR_UNSET OR_ALL ACCESS_CONF RSRC_CONF );
955 5 our @ARGS_HOW_CONSTS = qw( RAW_ARGS TAKE1 TAKE2 TAKE12 TAKE3 TAKE23 TAKE123
956 ITERATE ITERATE2 FLAG NO_ARGS );
957  
958  
959 5 our @EXPORT = ( @COMMON_CONSTS );
960 5 our @EXPORT_OK = ( @COMMON_CONSTS, @RESPONSE_CONSTS, @METHOD_CONSTS, @OPTIONS_CONSTS, @SATISFY_CONSTS,
961 @REMOTEHOST_CONSTS, @HTTP_CONSTS, @SERVER_CONSTS, @CONFIG_CONSTS, @TYPES_CONSTS,
962 @OVERRIDE_CONSTS, @ARGS_HOW_CONSTS);
963  
964 5 our %EXPORT_TAGS = ( common => \@COMMON_CONSTS,
965 response => [ @COMMON_CONSTS, @RESPONSE_CONSTS ],
966 methods => \@METHOD_CONSTS,
967 options => \@OPTIONS_CONSTS,
968 satisfy => \@SATISFY_CONSTS,
969 remotehost => \@REMOTEHOST_CONSTS,
970 http => \@HTTP_CONSTS,
971 server => \@SERVER_CONSTS,
972 config => \@CONFIG_CONSTS,
973 types => \@TYPES_CONSTS,
974 override => \@OVERRIDE_CONSTS,
975 args_how => \@ARGS_HOW_CONSTS, );
976  
977  
978 8 ▶sub OK { 0 }
Subroutine OK: called CC=1 SCAR=0.0
Pod undocumented
979 0 ▶sub DECLINED { -1 }
Subroutine DECLINED: not called CC=1 SCAR=6.9
Pod undocumented
980 0 ▶sub DONE { -2 }
Subroutine DONE: not called CC=1 SCAR=6.9
Pod undocumented
981  
982 # CONTINUE and NOT_AUTHORITATIVE are aliases for DECLINED.
983  
984 0 ▶sub CONTINUE { 100 }
Subroutine CONTINUE: not called CC=1 SCAR=6.9
Pod undocumented
985 0 ▶sub DOCUMENT_FOLLOWS { 200 }
Subroutine DOCUMENT_FOLLOWS: not called CC=1 SCAR=6.9
Pod undocumented
986 0 ▶sub NOT_AUTHORITATIVE { 203 }
Subroutine NOT_AUTHORITATIVE: not called CC=1 SCAR=6.9
Pod undocumented
987 0 ▶sub MOVED { 301 }
Subroutine MOVED: not called CC=1 SCAR=6.9
Pod undocumented
988 0 ▶sub REDIRECT { 302 }
Subroutine REDIRECT: not called CC=1 SCAR=6.9
Pod undocumented
989 0 ▶sub USE_LOCAL_COPY { 304 }
Subroutine USE_LOCAL_COPY: not called CC=1 SCAR=6.9
Pod undocumented
990 0 ▶sub BAD_REQUEST { 400 }
Subroutine BAD_REQUEST: not called CC=1 SCAR=6.9
Pod undocumented
991 0 ▶sub AUTH_REQUIRED { 401 }
Subroutine AUTH_REQUIRED: not called CC=1 SCAR=6.9
Pod undocumented
992 0 ▶sub FORBIDDEN { 403 }
Subroutine FORBIDDEN: not called CC=1 SCAR=6.9
Pod undocumented
993 0 ▶sub NOT_FOUND { 404 }
Subroutine NOT_FOUND: not called CC=1 SCAR=6.9
Pod undocumented
994 0 ▶sub SERVER_ERROR { 500 }
Subroutine SERVER_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
995 0 ▶sub NOT_IMPLEMENTED { 501 }
Subroutine NOT_IMPLEMENTED: not called CC=1 SCAR=6.9
Pod undocumented
996 0 ▶sub BAD_GATEWAY { 502 }
Subroutine BAD_GATEWAY: not called CC=1 SCAR=6.9
Pod undocumented
997  
998 5 ▶sub HTTP_OK { 200 }
Subroutine HTTP_OK: called CC=1 SCAR=0.0
Pod undocumented
999 0 ▶sub HTTP_NO_CONTENT { 204 }
Subroutine HTTP_NO_CONTENT: not called CC=1 SCAR=6.9
Pod undocumented
1000 0 ▶sub HTTP_MOVED_PERMANENTLY { 301 }
Subroutine HTTP_MOVED_PERMANENTLY: not called CC=1 SCAR=6.9
Pod undocumented
1001 0 ▶sub HTTP_MOVED_TEMPORARILY { 302 }
Subroutine HTTP_MOVED_TEMPORARILY: not called CC=1 SCAR=6.9
Pod undocumented
1002 0 ▶sub HTTP_NOT_MODIFIED { 304 }
Subroutine HTTP_NOT_MODIFIED: not called CC=1 SCAR=6.9
Pod undocumented
1003 0 ▶sub HTTP_BAD_REQUEST { 400 }
Subroutine HTTP_BAD_REQUEST: not called CC=1 SCAR=6.9
Pod undocumented
1004 0 ▶sub HTTP_UNAUTHORIZED { 401 }
Subroutine HTTP_UNAUTHORIZED: not called CC=1 SCAR=6.9
Pod undocumented
1005 0 ▶sub HTTP_FORBIDDEN { 403 }
Subroutine HTTP_FORBIDDEN: not called CC=1 SCAR=6.9
Pod undocumented
1006 0 ▶sub HTTP_NOT_FOUND { 404 }
Subroutine HTTP_NOT_FOUND: not called CC=1 SCAR=6.9
Pod undocumented
1007 0 ▶sub HTTP_METHOD_NOT_ALLOWED { 405 }
Subroutine HTTP_METHOD_NOT_ALLOWED: not called CC=1 SCAR=6.9
Pod undocumented
1008 0 ▶sub HTTP_NOT_ACCEPTABLE { 406 }
Subroutine HTTP_NOT_ACCEPTABLE: not called CC=1 SCAR=6.9
Pod undocumented
1009 0 ▶sub HTTP_LENGTH_REQUIRED { 411 }
Subroutine HTTP_LENGTH_REQUIRED: not called CC=1 SCAR=6.9
Pod undocumented
1010 0 ▶sub HTTP_PRECONDITION_FAILED { 412 }
Subroutine HTTP_PRECONDITION_FAILED: not called CC=1 SCAR=6.9
Pod undocumented
1011 0 ▶sub HTTP_INTERNAL_SERVER_ERROR { 500 }
Subroutine HTTP_INTERNAL_SERVER_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
1012 0 ▶sub HTTP_NOT_IMPLEMENTED { 501 }
Subroutine HTTP_NOT_IMPLEMENTED: not called CC=1 SCAR=6.9
Pod undocumented
1013 0 ▶sub HTTP_BAD_GATEWAY { 502 }
Subroutine HTTP_BAD_GATEWAY: not called CC=1 SCAR=6.9
Pod undocumented
1014 0 ▶sub HTTP_SERVICE_UNAVAILABLE { 503 }
Subroutine HTTP_SERVICE_UNAVAILABLE: not called CC=1 SCAR=6.9
Pod undocumented
1015 0 ▶sub HTTP_VARIANT_ALSO_VARIES { 506 }
Subroutine HTTP_VARIANT_ALSO_VARIES: not called CC=1 SCAR=6.9
Pod undocumented
1016  
1017 # methods
1018  
1019 0 ▶sub M_GET { 0 }
Subroutine M_GET: not called CC=1 SCAR=6.9
Pod undocumented
1020 0 ▶sub M_PUT { 1 }
Subroutine M_PUT: not called CC=1 SCAR=6.9
Pod undocumented
1021 0 ▶sub M_POST { 2 }
Subroutine M_POST: not called CC=1 SCAR=6.9
Pod undocumented
1022 0 ▶sub M_DELETE { 3 }
Subroutine M_DELETE: not called CC=1 SCAR=6.9
Pod undocumented
1023 0 ▶sub M_CONNECT { 4 }
Subroutine M_CONNECT: not called CC=1 SCAR=6.9
Pod undocumented
1024 0 ▶sub M_OPTIONS { 5 }
Subroutine M_OPTIONS: not called CC=1 SCAR=6.9
Pod undocumented
1025 0 ▶sub M_TRACE { 6 }
Subroutine M_TRACE: not called CC=1 SCAR=6.9
Pod undocumented
1026 0 ▶sub M_INVALID { 7 }
Subroutine M_INVALID: not called CC=1 SCAR=6.9
Pod undocumented
1027  
1028 # options
1029  
1030 0 ▶sub OPT_NONE { 0 }
Subroutine OPT_NONE: not called CC=1 SCAR=6.9
Pod undocumented
1031 0 ▶sub OPT_INDEXES { 1 }
Subroutine OPT_INDEXES: not called CC=1 SCAR=6.9
Pod undocumented
1032 0 ▶sub OPT_INCLUDES { 2 }
Subroutine OPT_INCLUDES: not called CC=1 SCAR=6.9
Pod undocumented
1033 0 ▶sub OPT_SYM_LINKS { 4 }
Subroutine OPT_SYM_LINKS: not called CC=1 SCAR=6.9
Pod undocumented
1034 0 ▶sub OPT_EXECCGI { 8 }
Subroutine OPT_EXECCGI: not called CC=1 SCAR=6.9
Pod undocumented
1035 0 ▶sub OPT_UNSET { 16 }
Subroutine OPT_UNSET: not called CC=1 SCAR=6.9
Pod undocumented
1036 0 ▶sub OPT_INCNOEXEC { 32 }
Subroutine OPT_INCNOEXEC: not called CC=1 SCAR=6.9
Pod undocumented
1037 0 ▶sub OPT_SYM_OWNER { 64 }
Subroutine OPT_SYM_OWNER: not called CC=1 SCAR=6.9
Pod undocumented
1038 0 ▶sub OPT_MULTI { 128 }
Subroutine OPT_MULTI: not called CC=1 SCAR=6.9
Pod undocumented
1039 0 ▶sub OPT_ALL { 15 }
Subroutine OPT_ALL: not called CC=1 SCAR=6.9
Pod undocumented
1040  
1041 # satisfy
1042  
1043 0 ▶sub SATISFY_ALL { 0 }
Subroutine SATISFY_ALL: not called CC=1 SCAR=6.9
Pod undocumented
1044 0 ▶sub SATISFY_ANY { 1 }
Subroutine SATISFY_ANY: not called CC=1 SCAR=6.9
Pod undocumented
1045 0 ▶sub SATISFY_NOSPEC { 2 }
Subroutine SATISFY_NOSPEC: not called CC=1 SCAR=6.9
Pod undocumented
1046  
1047 # remotehost
1048  
1049 0 ▶sub REMOTE_HOST { 0 }
Subroutine REMOTE_HOST: not called CC=1 SCAR=6.9
Pod undocumented
1050 0 ▶sub REMOTE_NAME { 1 }
Subroutine REMOTE_NAME: not called CC=1 SCAR=6.9
Pod undocumented
1051 0 ▶sub REMOTE_NOLOOKUP { 2 }
Subroutine REMOTE_NOLOOKUP: not called CC=1 SCAR=6.9
Pod undocumented
1052 0 ▶sub REMOTE_DOUBLE_REV { 3 }
Subroutine REMOTE_DOUBLE_REV: not called CC=1 SCAR=6.9
Pod undocumented
1053  
1054  
1055  
1056 0 ▶sub MODULE_MAGIC_NUMBER { "42" }
Subroutine MODULE_MAGIC_NUMBER: not called CC=1 SCAR=6.9
Pod undocumented
1057 0 ▶sub SERVER_VERSION { "1.x" }
Subroutine SERVER_VERSION: not called CC=1 SCAR=6.9
Pod undocumented
1058 0 ▶sub SERVER_BUILT { "199908" }
Subroutine SERVER_BUILT: not called CC=1 SCAR=6.9
Pod undocumented
1059  
1060  
1061  
1062 ##############################################################################
1063 #
1064 # Implementation of Apache::Request - a.k.a. libapreq
1065  
1066 package
1067 Apache::Request;
1068  
1069 5 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
1070 5 ▶use parent 'Apache';
Subroutine BEGIN: called CC=1 SCAR=0.0
1071  
1072 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
1073 0 my ($class, $r, %params) = @_;
1074  
1075 0 DEBUG('Apache::Request->new(%s) => %s', join(',', map { "$_=>'$params{$_}'" } keys %params ), $r);
1076 $r->{$_} = $params{$_}
1077 0 for qw(POST_MAX DISABLE_UPLOADS TEMP_DIR HOOK_DATA UPLOAD_HOOK);
1078  
1079 0 return bless $r, $class;
1080 }
1081  
1082 0 ▶sub instance {
Subroutine instance: not called CC=1 SCAR=6.9
Pod undocumented
1083 0 NYI_DEBUG('$apr->instance')
1084 }
1085  
1086  
1087 0 ▶sub parse {
Subroutine parse: not called CC=3 SCAR=24.8
Pod undocumented
1088 0 my $apr = shift;
1089 0 DEBUG('$apr->parse');
1090  
1091 0 my $params = $apr->{params} = Apache::Table->new($apr);
1092 0 my $uri = $apr->_uri;
1093 0 foreach my $key ($uri->query_param) {
1094 0 foreach my $value ($uri->query_param($key)) {
1095 0 $params->add($key, $value);
1096 }
1097 }
1098 0 return;
1099 }
1100  
1101  
1102 0 ▶sub param {
Subroutine param: not called CC=1 SCAR=6.9
Pod undocumented
1103 0 my $apr = shift;
1104 0 NYI_DEBUG('$apr->param')
1105 }
1106  
1107  
1108 0 ▶sub parms {
Subroutine parms: not called CC=3 SCAR=24.8
Pod undocumented
1109 0 my ($apr, $newval) = @_;
1110 0 ▶ DEBUG('$apr->parms(%s)', @_ > 1 ? "$newval" : '');
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
1111 0 ▶ $apr->parse unless $apr->{params};
Branch: 1 branch
BranchTrueFalseTotal
unless $apr->{"params"} 0 0 0
1112 0 return $apr->{params};
1113 }
1114  
1115 0 ▶sub upload {
Subroutine upload: not called CC=1 SCAR=6.9
Pod undocumented
1116 0 my $apr = shift;
1117 0 NYI_DEBUG('$apr->upload')
1118 }
1119  
1120 ###############################################################################
1121  
1122 package
1123 Apache::Upload;
1124  
1125 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
1126 0 NYI_DEBUG('Apache::Upload->name');
1127 }
1128  
1129 0 ▶sub filename {
Subroutine filename: not called CC=1 SCAR=6.9
Pod undocumented
1130 0 NYI_DEBUG('Apache::Upload->filename');
1131 }
1132  
1133 0 ▶sub fh {
Subroutine fh: not called CC=1 SCAR=6.9
Pod undocumented
1134 0 NYI_DEBUG('Apache::Upload->fh');
1135 }
1136  
1137 0 ▶sub size {
Subroutine size: not called CC=1 SCAR=6.9
Pod undocumented
1138 0 NYI_DEBUG('Apache::Upload->size');
1139 }
1140  
1141 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
1142 0 NYI_DEBUG('Apache::Upload->info');
1143 }
1144  
1145 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
1146 0 NYI_DEBUG('Apache::Upload->type');
1147 }
1148  
1149 0 ▶sub next {
Subroutine next: not called CC=1 SCAR=6.9
Pod undocumented
1150 0 NYI_DEBUG('Apache::Upload->next');
1151 }
1152  
1153 0 ▶sub tempname {
Subroutine tempname: not called CC=1 SCAR=6.9
Pod undocumented
1154 0 NYI_DEBUG('Apache::Upload->tempname');
1155 }
1156  
1157 0 ▶sub link {
Subroutine link: not called CC=1 SCAR=6.9
Pod undocumented
1158 0 NYI_DEBUG('Apache::Upload->link');
1159 }
1160  
1161 ################################################################################
1162  
1163 package
1164 Apache::Cookie;
1165  
1166 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
1167 0 NYI_DEBUG('Apache::Cookie->new');
1168 }
1169  
1170 0 ▶sub bake {
Subroutine bake: not called CC=1 SCAR=6.9
Pod undocumented
1171 0 NYI_DEBUG('$c->bake');
1172 }
1173  
1174 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
1175 0 NYI_DEBUG('$c->parse');
1176 }
1177  
1178 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
Pod undocumented
1179 0 NYI_DEBUG('$c->fetch');
1180 }
1181  
1182 0 ▶sub as_string {
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
1183 0 NYI_DEBUG('$c->as_string');
1184 }
1185  
1186 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
1187 0 NYI_DEBUG('$c->name');
1188 }
1189  
1190 0 ▶sub value {
Subroutine value: not called CC=1 SCAR=6.9
Pod undocumented
1191 0 NYI_DEBUG('$c->value');
1192 }
1193  
1194 0 ▶sub domain {
Subroutine domain: not called CC=1 SCAR=6.9
Pod undocumented
1195 0 NYI_DEBUG('$c->domain');
1196 }
1197  
1198 0 ▶sub path {
Subroutine path: not called CC=1 SCAR=6.9
Pod undocumented
1199 0 NYI_DEBUG('$c->path');
1200 }
1201  
1202 0 ▶sub expires {
Subroutine expires: not called CC=1 SCAR=6.9
Pod undocumented
1203 0 NYI_DEBUG('$c->expires');
1204 }
1205  
1206 0 ▶sub secure {
Subroutine secure: not called CC=1 SCAR=6.9
Pod undocumented
1207 0 NYI_DEBUG('$c->secure');
1208 }
1209  
1210  
1211 5 1;
« Apache.pm ↑ Summary Apache/RemoteClient.pm »