![]() |
Home / Documentation / 2.0 / API / | ![]() |
||
![]() ![]() ![]() |
||||
Apache::ServerUtil - Perl API for XXX | ||||
![]() ![]() |
|
||
use Apache::ServerUtil (); $s = Apache->server; my $srv_cfg = $s->dir_config; # get 'conf/' dir path using $s my $conf_dir = $s->server_root_relative('conf'); # server level PerlOptions flags lookup $s->push_handlers(ChildExit => \&child_exit) if $s->is_perl_option_enabled('ChildExit');
META: to be completed
Apache::ServerUtil
provides the Perl API for Apache server object.
META: to be completed
add_version_component
META: Autogenerated - needs to be reviewed/completed
Add a component to the version string
add_version_component($pconf_pool, $component);
$pconf
(APR::Pool
)
The pool to allocate the component from (should really be a
$pconf_pool
)
$component
(string)
The string to add
exists_config_define
Check for a definition from the server command line
$result = Apache::Server::exists_config_define($name);
$name
(string)
The define to check for
$result
(integer)
true if defined, false otherwise
For example:
print "this is mp2" if Apache::Server::exists_config_define('MODPERL2');
get_server_built
META: Autogenerated - needs to be reviewed/completed
Get the date and time that the server was built
$when_built = Apache::Server::get_server_built();
Returns the canonical form of the filename made absolute to
ServerRoot
:
$path = $s->server_root_relative($fname);
$s
(Apache::Server
)
$fname
(string)
$path
(string)
$fname
is appended to the value of ServerRoot
and returned. For
example:
my $log_dir = Apache::Server::server_root_relative($r->pool, 'logs');
If $fname
is not specified, the value of ServerRoot
is returned
with a trailing /
. (it's the same as using ''
as $fname
's
value).
Also see the Apache::Server::server_root
constant.
error_log2stderr
META: Autogenerated - needs to be reviewed/completed
Convert stderr to the error log
$s->error_log2stderr();
$s
(Apache::Server
)
The current server
psignature
META: Autogenerated - needs to be reviewed/completed
Get HTML describing the address and (optionally) admin of the server.
$sig = $r->psignature($prefix);
$r
(Apache::RequestRec
)
$prefix
(string)
Text which is prepended to the return value
$sig
(string)
HTML describing the server
dir_config
dir_config() provides an interface for the per-server variables
specified by the PerlSetVar
and PerlAddVar
directives, and also
can be manipulated via the APR::Table
methods.
$table = $s->dir_config(); $value = $s->dir_config($key); @values = $s->dir_config($key); $s->dir_config($key, $val);
$s
(Apache::Server
)
$key
(string)
$val
(string)
$ret
(scalar)
Depends on the passed arguments, see further discussion
The keys are case-insensitive.
$t = $s->dir_config();
dir_config() called in a scalar context without the $key
argument
returns a HASH reference blessed into the APR::Table class. This
object can be manipulated via the APR::Table methods. For available
methods see APR::Table.
@values = $s->dir_config($key);
If the $key
argument is passed in the list context a list of all
matching values will be returned. This method is ineffective for big
tables, as it does a linear search of the table. Thefore avoid using
this way of calling dir_config() unless you know that there could be
more than one value for the wanted key and all the values are wanted.
$value = $s->dir_config($key);
If the $key
argument is passed in the scalar context only a single
value will be returned. Since the table preserves the insertion order,
if there is more than one value for the same key, the oldest value
assosiated with the desired key is returned. Calling in the scalar
context is also much faster, as it'll stop searching the table as soon
as the first match happens.
$s->dir_config($key => $val);
If the $key
and the $val
arguments are used, the set() operation
will happen: all existing values associated with the key $key
(and
the key itself) will be deleted and $value
will be placed instead.
$s->dir_config($key => undef);
If $val
is undef the unset() operation will happen: all existing
values associated with the key $key
(and the key itself) will be
deleted.
is_perl_option_enabled
check whether a server level PerlOptions flag is enabled or not.
$result = $s->is_perl_option_enabled($flag);
$s
(Apache::Server
)
$flag
(string)
$result
(integer)
For example to check whether the ChildExit
hook is enabled (which
can be disabled with PerlOptions -ChildExit
) and configure some
handlers to run if enabled:
$s->push_handlers(ChildExit => \&child_exit) if $s->is_perl_option_enabled('ChildExit');
See also: PerlOptions and the equivalent function for directory level PerlOptions flags.
get_handlers
Returns a reference to a list of handlers enabled for a given phase.
@handlers = $s->get_handlers($hook_name);
$s
(Apache::Server
)
$hook_name
(string)
a string representing the phase to handle.
@handlers
(CODE ref or ref to ARRAY of CODE refs)
a list of references to the handler subroutines
For example:
@handlers = $s->get_handlers('PerlResponseHandler');
push_handlers
META: Autogenerated - needs to be reviewed/completed
Add one or more handlers to a list of handlers to be called for a given phase.
$s->push_handlers($hook_name => \&handler); $s->push_handlers($hook_name => [\&handler, \&handler2]);
$s
(Apache::Server
)
$hook_name
(string)
a string representing the phase to handle.
$handlers
(CODE ref or ref to ARRAY of CODE refs)
a reference to a list of references to the handler subroutines, or a single reference to a handler subroutine
Examples:
$s->push_handlers(PerlResponseHandler => \&handler); $s->push_handlers(PerlResponseHandler => [\&handler, \&handler2]);
# XXX: not implemented yet $s->push_handlers(PerlResponseHandler => sub {...});
set_handlers
META: Autogenerated - needs to be reviewed/completed
Set a list of handlers to be called for a given phase.
$s->set_handlers($hook_name => \&handler); $s->set_handlers($hook_name => [\&handler, \&handler2]);
$s
(Apache::Server
)
$hook_name
(string)
a string representing the phase to handle.
$handlers
(CODE ref or ref to ARRAY of CODE refs)
a reference to a list of references to the handler subroutines, or a single reference to a handler subroutine
Examples:
$s->set_handlers(PerlResponseHandler => \&handler); $s->set_handlers(PerlResponseHandler => [\&handler, \&handler2]);
# XXX: not implemented yet $s->set_handlers(PerlResponseHandler => sub {...});
method_register
META: Autogenerated - needs to be reviewed/completed
Register a new request method, and return the offset that will be associated with that method.
$ret = $p->method_register($methname);
$p
(APR::Pool
)
The pool to create registered method numbers from.
$methname
(string)
The name of the new method to register.
$ret
(integer)
Ab int value representing an offset into a bitmask.
get_status_line
META: Autogenerated - needs to be reviewed/completed
Return the Status-Line for a given status code (excluding the HTTP-Version field). If an invalid or unknown status code is passed, "500 Internal Server Error" will be returned.
$ret = get_status_line($status);
server
Get the main server's object
$main_s = Apache->server();
Apache
(class name)
$main_s
(Apache::Server
)
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 1.1.
|
![]() |
![]() ![]() ![]() |