![]() |
Home / Documentation / 2.0 / API / | ![]() |
||
![]() ![]() ![]() |
||||
Apache::RequestUtil - Perl API for Apache request record utils | ||||
![]() ![]() |
|
||
use Apache::RequestUtil (); # directory level PerlOptions flags lookup $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');
META: to be completed
default_type
META: Autogenerated - needs to be reviewed/completed
Retrieve the value of the DefaultType directive, or text/plain if not set
$ret = $r->default_type();
$r
(Apache::RequestRec
)
The current request
$ret
(string)
The default type
document_root
META: Autogenerated - needs to be reviewed/completed
Retrieve the document root for this server
$ret = $r->document_root();
$r
(Apache::RequestRec
)
The current request
$ret
(string)
The document root
get_limit_req_body
META: Autogenerated - needs to be reviewed/completed
Return the limit on bytes in request msg body
$ret = $r->get_limit_req_body();
$r
(Apache::RequestRec
)
The current request
$ret
(integer)
the maximum number of bytes in the request msg body
get_server_name
META: Autogenerated - needs to be reviewed/completed
Get the current server name from the request
$ret = $r->get_server_name();
$r
(Apache::RequestRec
)
The current request
$ret
(string)
the server name
get_server_port
META: Autogenerated - needs to be reviewed/completed
Get the current server port
$ret = $r->get_server_port();
$r
(Apache::RequestRec
)
$ret
(integer)
The server's port
is_initial_req
META: Autogenerated - needs to be reviewed/completed
Determine if the current request is the main request or a sub requests
$ret = $r->is_initial_req();
$r
(Apache::RequestRec
)
The current request
$ret
(integer)
add_config
META: Autogenerated - needs to be reviewed/completed
$ret = $r->add_config($lines, $path, $override);
$r
(Apache::RequestRec
)
$lines
(ARRAY ref)
$path
(scalar)
$override
(string)
$ret
(string)
location
META: Autogenerated - needs to be reviewed/completed
$location = $r->location($location);
$r
(Apache::RequestRec
)
$location
(string)
$location
(integer)
location_merge
META: Autogenerated - needs to be reviewed/completed
$ret = $r->location_merge($location);
$r
(Apache::RequestRec
)
$location
(string)
$ret
(integer)
pnotes
META: Autogenerated - needs to be reviewed/completed
Notes from one module to another
$pnotes = $r->pnotes(); $pnotes = $r->pnotes($new_pnotes);
$r
(Apache::RequestRec
)
$new_pnotes
(APR::Table
)
$pnotes
(APR::Table
)
Similar to
(Apache::RequestRec
),
but values can be any perl variables. That also means that it can be
used only between perl modules.
no_cache
META: Autogenerated - needs to be reviewed/completed
$ret = $r->no_cache($flag);
$r
(Apache::RequestRec
)
$flag
(number)
$ret
(integer)
as_string
META: Autogenerated - needs to be reviewed/completed
$string = $r->as_string();
$r
(Apache::RequestRec
)
$string
(string)
get_handlers
Returns a reference to a list of handlers enabled for a given phase.
@handlers = $r->get_handlers($hook_name);
$r
(Apache::RequestRec
)
$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 = $r->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.
$r->push_handlers($hook_name => \&handler); $r->push_handlers($hook_name => [\&handler, \&handler2]);
$r
(Apache::RequestRec
)
$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:
$r->push_handlers(PerlResponseHandler => \&handler); $r->push_handlers(PerlResponseHandler => [\&handler, \&handler2]);
# XXX: not implemented yet $r->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.
$r->set_handlers($hook_name => \&handler); $r->set_handlers($hook_name => [\&handler, \&handler2]);
$r
(Apache::RequestRec
)
$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:
$r->set_handlers(PerlResponseHandler => \&handler); $r->set_handlers(PerlResponseHandler => [\&handler, \&handler2]);
# XXX: not implemented yet $r->set_handlers(PerlResponseHandler => sub {...});
set_basic_credentials
META: Autogenerated - needs to be reviewed/completed
$r->set_basic_credentials($username, $password);
$r
(Apache::RequestRec
)
$username
(string)
$password
(string)
slurp_filename
META: Autogenerated - needs to be reviewed/completed
Return a reference to contents of $r->filename
.
$content = $r->slurp_filename($tainted);
$r
(Apache::RequestRec
)
$tainted
(number)
By default the returned data is tainted (if run under -T
). If an
optional $tainted
flag is set to zero, the data will be marked as
non-tainted. Do not set this flag to zero unless you know what you are
doing, you may create a security hole in your program if you do. For
more information see the perlsec manpage. If you wonder why this
option is available, it is used internally by the
ModPerl::Registry
handler and
friends, because the CGI scripts that it reads are considered safe
(you could just as well require()
them).
$content
(scalar)
is_perl_option_enabled
check whether a directory level PerlOptions flag is enabled or not.
$result = $r->is_perl_option_enabled($flag);
$r
(Apache::RequestRec
)
$flag
(string)
$result
(integer)
For example to check whether the SetupEnv
option is enabled for the
current request (which can be disabled with PerlOptions -SetupEnv
)
and populate the environment variables table if disabled:
$r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');
See also: PerlOptions and the equivalent function for server level PerlOptions flags.
dir_config
dir_config() provides an interface for the per-directory variable
specified by the PerlSetVar
and PerlAddVar
directives, and also
can be manipulated via the APR::Table
methods.
$table = $r->dir_config(); $value = $r->dir_config($key); @values = $r->dir_config($key); $r->dir_config($key, $val);
$r
(Apache::RequestRec
)
$key
(string)
$val
(string)
$ret
(scalar)
Depends on the passed arguments, see further discussion
The keys are case-insensitive.
$apr_table = $r->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
the APR::Table
manpage.
@values = $r->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 = $r->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.
$r->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.
$r->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.
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 1.1.
|
![]() |
![]() ![]() ![]() |