<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># 
# /*
#  * *********** WARNING **************
#  * This file generated by ModPerl::WrapXS/0.01
#  * Any changes made here will be lost
#  * ***********************************
#  * 01: lib/ModPerl/Code.pm:709
#  * 02: lib/ModPerl/WrapXS.pm:633
#  * 03: lib/ModPerl/WrapXS.pm:1182
#  * 04: Makefile.PL:427
#  * 05: Makefile.PL:329
#  * 06: Makefile.PL:58
#  */
# 


package Apache2::RequestUtil;

use strict;
use warnings FATAL =&gt; 'all';



use Apache2::XSLoader ();
our $VERSION = '2.000008';
Apache2::XSLoader::load __PACKAGE__;



1;
__END__

=head1 NAME

Apache2::RequestUtil - Perl API for Apache request record utils




=head1 Synopsis

  use Apache2::RequestUtil ();
  
  # add httpd config dynamically
  $r-&gt;add_config(['require valid-user']);
  
  # dump the request object as a string
  print $r-&gt;as_string();
  
  # default content_type
  $content_type = $r-&gt;default_type();
  
  # get PerlSetVar/PerlAddVar values
  @values = $r-&gt;dir_config-&gt;get($key);
  
  # get server docroot
  $docroot = $r-&gt;document_root();
  
  # set server docroot
  $r-&gt;document_root($new_root);
  
  # what are the registered perl handlers for a given phase
  my @handlers = @{ $r-&gt;get_handlers('PerlResponseHandler') || [] };
  
  # push a new handler for a given phase
  $r-&gt;push_handlers(PerlCleanupHandler =&gt; \&amp;handler);
  
  # set handlers for a given phase (resetting previous values)
  $r-&gt;set_handlers(PerlCleanupHandler =&gt; []);
  
  # what's the request body limit
  $limit = $r-&gt;get_limit_req_body();
  
  # server and port names
  $server = $r-&gt;get_server_name();
  $port   = $r-&gt;get_server_port();
  
  # what string Apache is going to send for a given status code
  $status_line = Apache2::RequestUtil::get_status_line(404);
  
  # are we in the main request?
  $is_initial = $r-&gt;is_initial_req();
  
  # directory level PerlOptions flags lookup
  $r-&gt;subprocess_env unless $r-&gt;is_perl_option_enabled('SetupEnv');
  
  # current &lt;Location&gt; value
  $location = $r-&gt;location();
  
  # merge a &lt;Location&gt; container in a request object
  $r-&gt;location_merge($location);
  
  # create a new Apache2::RequestRec object
  $r = Apache2::RequestRec-&gt;new($c);
  
  # tell the client not to cache the response
  $r-&gt;no_cache($boolean);
  
  # share perl objects by reference like $r-&gt;notes
  $r-&gt;pnotes($key =&gt; [$obj1, $obj2]);
  
  # get HTML signature
  $sig = $r-&gt;psignature($prefix);
  
  # get the global request object (requires PerlOptions +GlobalRequest)
  $r = Apache2::RequestUtil-&gt;request;
  
  # insert auth credentials into the request as if the client did that
  $r-&gt;set_basic_credentials($username, $password);
  
  # slurp the contents of $r-&gt;filename
  my $content = ${ $r-&gt;slurp_filename() };
  
  # terminate the current child after this request
  $r-&gt;child_terminate();







=head1 Description

C&lt;Apache2::RequestUtil&gt; provides the L&lt;Apache request
object|docs::2.0::api::Apache2::RequestRec&gt; utilities API.





=head1 API




=head2 C&lt;add_config&gt;

Dynamically add Apache configuration at request processing runtime:

  $r-&gt;add_config($lines);
  $r-&gt;add_config($lines, $override);
  $r-&gt;add_config($lines, $override, $path);
  $r-&gt;add_config($lines, $override, $path, $override_opts);

Configuration directives are processed as if given in a C&lt;E&lt;lt&gt;LocationE&lt;gt&gt;&gt;
block.

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$lines&gt; (ARRAY ref)

An ARRAY reference containing configuration lines per element, without
the new line terminators.

=item opt arg2: C&lt;$override&gt; ( C&lt;L&lt;Apache2::Const override
constant|docs::2.0::api::Apache2::Const&gt;&gt; )

Which allow-override bits are set

Default value is:
C&lt;L&lt;Apache2::Const::OR_AUTHCFG|docs::2.0::api::Apache2::Const/C_Apache2__Const__OR_AUTHCFG_&gt;&gt;

=item opt arg3: C&lt;$path&gt; ( string )

Set the C&lt;L&lt;Apache2::CmdParms object|docs::2.0::api::Apache2::CmdParms&gt;&gt; C&lt;path&gt; component.
This is the path of the C&lt;E&lt;lt&gt;LocationE&lt;gt&gt;&gt; block. Some directives need this,
for example C&lt;ProxyPassReverse&gt;.

If an empty string is passed a C&lt;NULL&gt; pointer is passed further at C-level.
This is necessary to make something like this work:

  $r-&gt;add_config( [
	 	   '&lt;Directory /&gt;',
		   'AllowOverride Options AuthConfig',
		   '&lt;/Directory&gt;',
                  ], ~0, '' );

Note: C&lt;AllowOverride&gt; is valid only in directory context.

B&lt;Caution:&gt; Some directives need a non-empty path otherwise they cause
segfaults. Thus, use the empty path with caution.

Default value is: C&lt;/&gt;

=item opt arg4: C&lt;$override_opts&gt; ( C&lt;L&lt;Apache2::Const options
constant|docs::2.0::api::Apache2::Const&gt;&gt; )

Apache limits the applicable directives in certain situations with
C&lt;AllowOverride&gt;. With Apache 2.2 comes the possibility to enable or
disable single options, for example

  AllowOverride AuthConfig Options=ExecCGI,Indexes

Internally, this directive is parsed into 2 bit fields that are represented
by the C&lt;$override&gt; and C&lt;$override_opts&gt; parameters to C&lt;add_config&gt;.
The above example is parsed into an C&lt;$override&gt; with 2 bits set, one for
C&lt;AuthConfig&gt; the other for C&lt;Options&gt; and an C&lt;$override_opts&gt; with
2 bits set for ExecCGI and Indexes.

When applying other directives, for example C&lt;AuthType&gt; or C&lt;Options&gt; the
appropriate bits in C&lt;$override&gt; must be set. For the C&lt;Options&gt; directive
additionally C&lt;$override_opts&gt; bits must be set.

The C&lt;$override&gt; and C&lt;$override_opts&gt; parameters to C&lt;add_config&gt; are
valid while applying C&lt;$lines&gt;.

C&lt;$override_opts&gt; is new in Apache 2.2. The mod_perl implementation for
Apache 2.0 lets you pass the parameter but ignores it.

Default for C&lt;$override_opts&gt; is:
C&lt;L&lt;Apache2::Const::OPT_UNSET|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_UNSET_&gt;&gt; |
C&lt;L&lt;Apache2::Const::OPT_ALL|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_ALL_&gt;&gt; |
C&lt;L&lt;Apache2::Const::OPT_INCNOEXEC|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_INCNOEXEC_&gt;&gt; |
C&lt;L&lt;Apache2::Const::OPT_SYM_OWNER|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_SYM_OWNER_&gt;&gt; |
C&lt;L&lt;Apache2::Const::OPT_MULTI|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_MULTI_&gt;&gt;

That means, all options are allowed.

=item ret: no return value

=item since: 2.0.00, C&lt;$path&gt; and C&lt;$override_opts&gt; since 2.0.3

=back

See also:
C&lt;L&lt;$s-E&lt;gt&gt;add_config|docs::2.0::api::Apache2::ServerUtil/C_add_config_&gt;&gt;

For example:

  use Apache2::RequestUtil ();
  use Apache2::Access ();

  $r-&gt;add_config(['require valid-user']);

  # this regards the current AllowOverride setting
  $r-&gt;add_config(['AuthName secret',
                  'AuthType Basic',
                  'Options ExecCGI'],
                 $r-&gt;allow_override, $path, $r-&gt;allow_override_opts);





=head2 C&lt;as_string&gt;

Dump the request object as a string

  $dump = $r-&gt;as_string();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item ret: C&lt;$dump&gt; ( string )

=item since: 2.0.00

=back

Dumps various request and response headers (mainly useful for
debugging)




=head2 C&lt;child_terminate&gt;

Terminate the current worker process as soon as the current request is
over

  $r-&gt;child_terminate();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item ret: no return value

=item since: 2.0.00

=back

This method is not supported in threaded MPMs



=head2 C&lt;default_type&gt;

Retrieve the value of the DefaultType directive for the current
request. If not set C&lt;text/plain&gt; is returned.

  $content_type = $r-&gt;default_type();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

The current request

=item ret: C&lt;$content_type&gt; ( string )

The default type

=item since: 2.0.00

=item removed from the C&lt;httpd&gt; API in version 2.3.2

=back






=head2 C&lt;dir_config&gt;

C&lt;$r-E&lt;gt&gt;dir_config()&gt; provides an interface for the per-directory
variable specified by the C&lt;PerlSetVar&gt; and C&lt;PerlAddVar&gt; directives,
and also can be manipulated via the
C&lt;L&lt;APR::Table|docs::2.0::api::APR::Table&gt;&gt; methods.

  $table  = $r-&gt;dir_config();
  $value  = $r-&gt;dir_config($key);
  @values = $r-&gt;dir_config-&gt;get($key);
  $r-&gt;dir_config($key, $val);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item opt arg2: C&lt;$key&gt; ( string )

Key string

=item opt arg3: C&lt;$val&gt; ( string )

Value string

=item ret: ...

Depends on the passed arguments, see further discussion

=item since: 2.0.00

=back

The keys are case-insensitive.

  $apr_table = $r-&gt;dir_config();

dir_config() called in a scalar context without the C&lt;$key&gt; argument
returns a I&lt;HASH&gt; reference blessed into the
C&lt;L&lt;APR::Table|docs::2.0::api::APR::Table&gt;&gt; class. This object can be
manipulated via the C&lt;L&lt;APR::Table|docs::2.0::api::APR::Table&gt;&gt;
methods. For available methods see
the C&lt;L&lt;APR::Table|docs::2.0::api::APR::Table&gt;&gt; manpage.

  $value = $r-&gt;dir_config($key);

If the C&lt;$key&gt; 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.

  @values = $r-&gt;dir_config-&gt;get($key);

To receive a list of values you must use C&lt;get()&gt; method from the
C&lt;L&lt;APR::Table|docs::2.0::api::APR::Table&gt;&gt; class.

  $r-&gt;dir_config($key =&gt; $val);

If the C&lt;$key&gt; and the C&lt;$val&gt; arguments are used, the set() operation
will happen: all existing values associated with the key C&lt;$key&gt; (and
the key itself) will be deleted and C&lt;$value&gt; will be placed instead.

  $r-&gt;dir_config($key =&gt; undef);

If C&lt;$val&gt; is I&lt;undef&gt; the unset() operation will happen: all existing
values associated with the key C&lt;$key&gt; (and the key itself) will be
deleted.







=head2 C&lt;document_root&gt;

Retrieve the document root for this server

  $docroot = $r-&gt;document_root();
  $docroot = $r-&gt;document_root($new_root);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

The current request

=item opt arg1: C&lt;$new_root&gt;

Sets the document root to a new value B&lt;only for the duration of the
current request&gt;.

Note the L&lt;limited functionality under threaded
MPMs|docs::2.0::api::Apache2::ServerRec/Limited_Functionality_under_Threaded_MPMs&gt;.

=item ret: C&lt;$docroot&gt; ( string )

The document root

=item since: 2.0.00

=back








=head2 C&lt;get_handlers&gt;

Returns a reference to a list of handlers enabled for a given phase.

  $handlers_list = $r-&gt;get_handlers($hook_name);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$hook_name&gt; ( string )

a string representing the phase to handle (e.g. C&lt;PerlLogHandler&gt;)

=item ret: C&lt;$handlers_list&gt; (ref to an ARRAY of CODE refs)

a list of handler subroutines CODE references

=item since: 2.0.00

=back

See also:
C&lt;L&lt;$s-E&lt;gt&gt;add_config|docs::2.0::api::Apache2::ServerUtil/C_get_handlers_&gt;&gt;

For example:

A list of handlers configured to run at the response phase:

  my @handlers = @{ $r-&gt;get_handlers('PerlResponseHandler') || [] };







=head2 C&lt;get_limit_req_body&gt;

Return the limit on bytes in request msg body

  $limit = $r-&gt;get_limit_req_body();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

The current request

=item ret: C&lt;$limit&gt; (integer)

the maximum number of bytes in the request msg body

=item since: 2.0.00

=back





=head2 C&lt;get_server_name&gt;

Get the current request's server name

  $server = $r-&gt;get_server_name();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

The current request

=item ret: C&lt;$server&gt; ( string )

the server name

=item since: 2.0.00

=back

For example, consruct a hostport string:

  use Apache2::RequestUtil ();
  my $hostport = join ':', $r-&gt;get_server_name, $r-&gt;get_server_port;





=head2 C&lt;get_server_port&gt;

Get the current server port

  $port = $r-&gt;get_server_port();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

The current request

=item ret: C&lt;$port&gt; ( integer )

The server's port number

=item since: 2.0.00

=back

For example, consruct a hostport string:

  use Apache2::RequestUtil ();
  my $hostport = join ':', $r-&gt;get_server_name, $r-&gt;get_server_port;







=head2 C&lt;get_status_line&gt;

Return the C&lt;Status-Line&gt; for a given status code (excluding the
HTTP-Version field).

  $status_line = Apache2::RequestUtil::get_status_line($status);

=over 4

=item arg1: C&lt;$status&gt; (integer)

The HTTP status code

=item ret: C&lt;$status_line&gt; ( string )

The Status-Line

If an invalid or unknown status code is passed, C&lt;"500 Internal Server
Error"&gt; will be returned.

=item since: 2.0.00

=back

For example:

  use Apache2::RequestUtil ();
  print Apache2::RequestUtil::get_status_line(400);

will print:

  400 Bad Request





=head2 C&lt;is_initial_req&gt;

Determine whether the current request is the main request or a
sub-request

  $is_initial = $r-&gt;is_initial_req();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

A request or a sub-request object

=item ret: C&lt;$is_initial&gt; ( boolean )

If true -- it's the main request, otherwise it's a sub-request

=item since: 2.0.00

=back







=head2 C&lt;is_perl_option_enabled&gt;

check whether a directory level C&lt;PerlOptions&gt; flag is enabled or not.

  $result = $r-&gt;is_perl_option_enabled($flag);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$flag&gt; ( string )

=item ret: C&lt;$result&gt; ( boolean )

=item since: 2.0.00

=back

For example to check whether the C&lt;SetupEnv&gt; option is enabled for the
current request (which can be disabled with C&lt;PerlOptions -SetupEnv&gt;)
and populate the environment variables table if disabled:

  $r-&gt;subprocess_env unless $r-&gt;is_perl_option_enabled('SetupEnv');

See also:
L&lt;PerlOptions|docs::2.0::user::config::config/C_PerlOptions_&gt; and
L&lt;the equivalent function for server level PerlOptions
flags|docs::2.0::api::Apache2::ServerUtil/C_is_perl_option_enabled_&gt;.





=head2 C&lt;location&gt;

Get the path of the E&lt;lt&gt;LocationE&lt;gt&gt; section from which the current
C&lt;Perl*Handler&gt; is being called.

  $location = $r-&gt;location();

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item ret: C&lt;$location&gt; ( string )

=item since: 2.0.00

=back






=head2 C&lt;location_merge&gt;

Merge a given C&lt;E&lt;lt&gt;LocationE&lt;gt&gt;&gt; container into the current request
object:

  $ret = $r-&gt;location_merge($location);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$location&gt; ( string )

The argument in a C&lt;E&lt;lt&gt;LocationE&lt;gt&gt;&gt; section. For example to merge
a container:

  &lt;Location /foo&gt;
      ...
  &lt;/Location&gt;

that argument will be I&lt;/foo&gt;

=item ret: C&lt;$ret&gt; ( boolean )

a true value if the merge was successful (i.e. the request
C&lt;$location&gt; match was found), otherwise false.

=item since: 2.0.00

=back

Useful for insertion of a configuration section into a custom
C&lt;Apache2::RequestRec&gt; object, created via the
C&lt;Apache2::RequestRec-E&lt;gt&gt;new()&gt; method. See for example the L&lt;Command
Server protocol
example|docs::2.0::user::handlers::protocols/Command_Server&gt;.





=head2 C&lt;new&gt;

Create a new C&lt;Apache2::RequestRec&gt; object.

  $r = Apache2::RequestRec-&gt;new($c);
  $r = Apache2::RequestRec-&gt;new($c, $pool);

=over 4

=item obj: C&lt;Apache2::RequestRec&gt;
( C&lt;L&lt;Apache2::RequestRec class name|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$c&gt;
(C&lt;L&lt;Apache2::Connection object|docs::2.0::api::Apache2::Connection&gt;&gt;)

=item opt arg2: C&lt;$pool&gt;

If no C&lt;$pool&gt; argument is passed, C&lt;$c-E&lt;gt&gt;pool&gt; is used. That means
that the created C&lt;Apache2::RequestRec&gt; object will be valid as long as
the connection object is valid.

=item ret: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item since: 2.0.00

=back

It's possible to reuse the HTTP framework features outside the
familiar HTTP request cycle. It's possible to write your own full or
partial HTTP implementation without needing a running Apache
server. You will need the C&lt;Apache2::RequestRec&gt; object in order to be
able to reuse the rich functionality supplied via this object.

See for example the L&lt;Command Server protocol
example|docs::2.0::user::handlers::protocols/Command_Server&gt; which
reuses HTTP AAA model under non-HTTP protocol.







=head2 C&lt;no_cache&gt;

Add/remove cache control headers:

  $prev_no_cache = $r-&gt;no_cache($boolean);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$boolean&gt; ( boolean )

A true value sets the C&lt;no_cache&gt; request record member to a true
value and inserts:

  Pragma: no-cache
  Cache-control: no-cache

into the response headers, indicating that the data being returned is
volatile and the client should not cache it.

A false value unsets the C&lt;no_cache&gt; request record member and the
mentioned headers if they were previously set.

=item ret: C&lt;$prev_no_cache&gt; ( boolean )

Should you care, the C&lt;no_cache&gt; request record member value prior to
the change is returned.

=item since: 2.0.00

=back

This method should be invoked before any response data has been sent
out.





=head2 C&lt;pnotes&gt;

Share Perl variables between Perl HTTP handlers

  # to share variables by value and not reference, $val should be a lexical.
  $old_val  = $r-&gt;pnotes($key =&gt; $val);
  $val      = $r-&gt;pnotes($key);
  $hash_ref = $r-&gt;pnotes();

B&lt;Note:&gt; sharing variables really means it. The variable is not copied.
Only its reference count is incremented. If it is changed after being
put in pnotes that change also affects the stored value. The following
example illustrates the effect:

  my $v=1;                     my $v=1;
  $r-&gt;pnotes( 'v'=&gt;$v );       $r-&gt;pnotes-&gt;{v}=$v;
  $v++;                        $v++;
  my $x=$r-&gt;pnotes('v');       my $x=$r-&gt;pnotes-&gt;{v};

In both cases C&lt;$x&gt; is C&lt;2&gt; not C&lt;1&gt;. See also C&lt;Apache2::SafePnotes&gt; on
CPAN.

There has been a lot of discussion advocating for pnotes sharing variables
by value and not reference.  Sharing by reference can create 'spooky action
at a distance' effects when the sharing is assumed to share a copy of the
value.  Tim Bunce offers the following summary and suggestion for sharing
by value.

What's wrong with this code:

  sub foo {
      my ($r, $status, $why) = @_;
      $r-&gt;pnotes('foo', ($why) ? "$status:$why" : $status);
      return;
  }

Nothing, except it doesn't work as expected due to this pnotes bug: If the 
same code is called in a sub-request then the pnote of $r-E&lt;gt&gt;prev is magically 
updated at a distance to the same value!

Try explain why that is to anyone not deeply familar with perl internals!

The fix is to avoid pnotes taking a ref to the invisible op_targ embededed in 
the code by passing a simple lexical variable as the actual argument. That can be done in-line like this:

  sub mark_as_internally_redirected {
      my ($r, $status, $why) = @_;
      $r-&gt;pnotes('foo', my $tmp = (($why) ? "$status:$why" : $status));
      return;
  }

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item opt arg1: C&lt;$key&gt; ( string )

A key value

=item opt arg2: C&lt;$val&gt; ( SCALAR )

Any scalar value (e.g. a reference to an array)

=item ret: (3 different possible values)

if both, C&lt;$key&gt; and C&lt;$val&gt; are passed the previous value for C&lt;$key&gt;
is returned if such existed, otherwise C&lt;undef&gt; is returned.

if only C&lt;$key&gt; is passed, the current value for the given key is
returned.

if no arguments are passed, a hash reference is returned, which can
then be directly accessed without going through the C&lt;pnotes()&gt;
interface.

=item since: 2.0.00

=back

This method provides functionality similar to
(C&lt;L&lt;Apache2::RequestRec::notes|docs::2.0::api::Apache2::RequestRec/C_notes_&gt;&gt;),
but values can be any Perl variables. That also means that it can be
used only between Perl modules.

The values get reset automatically at the end of each HTTP request.

Examples:

Set a key/value pair:

  $r-&gt;pnotes(foo =&gt; [1..5]);

Get the value:

  $val = $r-&gt;pnotes("foo");

C&lt;$val&gt; now contains an array ref containing 5 elements (C&lt;1..5&gt;).

Now change the existing value:

  $old_val = $r-&gt;pnotes(foo =&gt; ['a'..'c']);
  $val = $r-&gt;pnotes("foo");

C&lt;$old_val&gt; now contains an array ref with 5 elements (C&lt;1..5&gt;) and
C&lt;$val&gt; contains an array ref with 3 elements C&lt;'a'&gt;, C&lt;'b'&gt;, C&lt;'c'&gt;.

Alternatively you can access the hash reference with all pnotes
values:

  $pnotes = $r-&gt;pnotes;

Now we can read what's in there for the key I&lt;foo&gt;:

  $val = $pnotes-&gt;{foo};

and as before C&lt;$val&gt; still gives us an array ref with 3 elements
C&lt;'a'&gt;, C&lt;'b'&gt;, C&lt;'c'&gt;.

Now we can add elements to it:

  push @{ $pnotes{foo} }, 'd'..'f';

and we can try to retrieve them using the hash and non-hash API:

  $val1 = $pnotes{foo};
  $val2 = $r-&gt;pnotes("foo");

Both C&lt;$val1&gt; and C&lt;$val2&gt; contain an array ref with 6 elements
(letters 'a' to 'f').

Finally to reset an entry you could just assign C&lt;undef&gt; as a value:

  $r-&gt;pnotes(foo =&gt; undef);

but the entry for the key I&lt;foo&gt; still remains with the value
C&lt;undef&gt;. If you really want to completely remove it, use the hash
interface:

  delete $r-&gt;pnotes-&gt;{foo};








=head2 C&lt;psignature&gt;

Get HTML describing the address and (optionally) admin of the server.

  $sig = $r-&gt;psignature($prefix);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$prefix&gt; ( string )

Text which is prepended to the return value

=item ret: C&lt;$sig&gt; ( string )

HTML text describing the server. Note that depending on the value of
the C&lt;ServerSignature&gt; directive, the function may return the address,
including the admin information or nothing at all.

=item since: 2.0.00

=back







=head2 C&lt;request&gt;

Get/set the ( C&lt;L&lt;Apache2::RequestRec
object|docs::2.0::api::Apache2::RequestRec&gt;&gt; ) object for the current
request.

  $r = Apache2::RequestUtil-&gt;request;
       Apache2::RequestUtil-&gt;request($new_r);

=over 4

=item obj: C&lt;Apache2&gt; (class name)

The Apache class name

=item opt arg1: C&lt;$new_r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item ret: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item since: 2.0.00

=back

The get-able part of this method is only available if C&lt;L&lt;PerlOptions
+GlobalRequest|docs::2.0::user::config::config/C_GlobalRequest_&gt;&gt; is
in effect or if C&lt;Apache2-E&lt;gt&gt;request($new_r)&gt; was called earlier. So
instead of setting C&lt;L&lt;PerlOptions
+GlobalRequest|docs::2.0::user::config::config/C_GlobalRequest_&gt;&gt;, one
can set the global request from within the handler.






=head2 C&lt;push_handlers&gt;

Add one or more handlers to a list of handlers to be called for a
given phase.

  $ok = $r-&gt;push_handlers($hook_name =&gt; \&amp;handler);
  $ok = $r-&gt;push_handlers($hook_name =&gt; ['Foo::Bar::handler', \&amp;handler2]);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$hook_name&gt; ( string )

the phase to add the handlers to

=item arg2: C&lt;$handlers&gt; ( CODE ref or SUB name or an ARRAY ref )

a single handler CODE reference or just a name of the subroutine
(fully qualified unless defined in the current package).

if more than one passed, use a reference to an array of CODE refs
and/or subroutine names.

=item ret: C&lt;$ok&gt; ( boolean )

returns a true value on success, otherwise a false value

=item since: 2.0.00

See also:
C&lt;L&lt;$s-E&lt;gt&gt;add_config|docs::2.0::api::Apache2::ServerUtil/C_push_handlers_&gt;&gt;

Note that to push input/output filters you have to use
C&lt;L&lt;Apache2::Filter|docs::2.0::api::Apache2::Filter&gt;&gt; methods:
C&lt;L&lt;add_input_filter|docs::2.0::api::Apache2::Filter/C_add_input_filter_&gt;&gt;
and
C&lt;L&lt;add_output_filter|docs::2.0::api::Apache2::Filter/C_add_output_filter_&gt;&gt;.

=back

Examples:

A single handler:

  $r-&gt;push_handlers(PerlResponseHandler =&gt; \&amp;handler);

Multiple handlers:

  $r-&gt;push_handlers(PerlFixupHandler =&gt; ['Foo::Bar::handler', \&amp;handler2]);

Anonymous functions:

  $r-&gt;push_handlers(PerlLogHandler =&gt; sub { return Apache2::Const::OK });






=head2 C&lt;set_basic_credentials&gt;

Populate the incoming request headers table (C&lt;headers_in&gt;) with
authentication headers for Basic Authorization as if the client has
submitted those in first place:

  $r-&gt;set_basic_credentials($username, $password);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$username&gt; ( string )

=item arg2: C&lt;$password&gt; ( string )

=item ret: no return value

=item since: 2.0.00

=back

See for example the L&lt;Command Server protocol
example|docs::2.0::user::handlers::protocols/Command_Server&gt; which
reuses HTTP AAA model under non-HTTP protocol.







=head2 C&lt;set_handlers&gt;

Set a list of handlers to be called for a given phase. Any previously
set handlers are forgotten.

  $ok = $r-&gt;set_handlers($hook_name =&gt; \&amp;handler);
  $ok = $r-&gt;set_handlers($hook_name =&gt; ['Foo::Bar::handler', \&amp;handler2]);
  $ok = $r-&gt;set_handlers($hook_name =&gt; []);
  $ok = $r-&gt;set_handlers($hook_name =&gt; undef);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$hook_name&gt; ( string )

the phase to set the handlers in

=item arg2: C&lt;$handlers&gt; (CODE ref or SUB name or an ARRAY ref)

a reference to a single handler CODE reference or just a name of the
subroutine (fully qualified unless defined in the current package).

if more than one passed, use a reference to an array of CODE refs
and/or subroutine names.

if the argument is C&lt;undef&gt; or C&lt;[]&gt; the list of handlers is reset to
zero.

=item ret: C&lt;$ok&gt; ( boolean )

returns a true value on success, otherwise a false value

=item since: 2.0.00

=back

See also:
C&lt;L&lt;$s-E&lt;gt&gt;add_config|docs::2.0::api::Apache2::ServerUtil/C_set_handlers_&gt;&gt;

Examples:

A single handler:

  $r-&gt;set_handlers(PerlResponseHandler =&gt; \&amp;handler);

Multiple handlers:

  $r-&gt;set_handlers(PerlFixupHandler =&gt; ['Foo::Bar::handler', \&amp;handler2]);

Anonymous functions:

  $r-&gt;set_handlers(PerlLogHandler =&gt; sub { return Apache2::Const::OK });

Reset any previously set handlers:

  $r-&gt;set_handlers(PerlCleanupHandler =&gt; []);

or

  $r-&gt;set_handlers(PerlCleanupHandler =&gt; undef);







=head2 C&lt;slurp_filename&gt;

Slurp the contents of C&lt;$r-E&lt;gt&gt;filename&gt;:

  $content_ref = $r-&gt;slurp_filename($tainted);

=over 4

=item obj: C&lt;$r&gt;
( C&lt;L&lt;Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec&gt;&gt; )

=item arg1: C&lt;$tainted&gt; (number)

If the server is run under the tainting mode (C&lt;-T&gt;) which we hope you
do, by default the returned data is tainted. If an optional
C&lt;$tainted&gt; flag is set to zero, the data will be marked as
non-tainted.

Do B&lt;not&gt; 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 I&lt;perlsec&gt; manpage.

If you wonder why this option is available, it is used internally by
the C&lt;L&lt;ModPerl::Registry|docs::2.0::api::ModPerl::Registry&gt;&gt; handler
and friends, because the CGI scripts that it reads are considered safe
(you could just as well C&lt;require()&gt; them).

=item ret: C&lt;$content_ref&gt; ( SCALAR ref )

A reference to a string with the contents

=item excpt: C&lt;L&lt;APR::Error|docs::2.0::api::APR::Error&gt;&gt;

Possible error codes could be:
C&lt;L&lt;APR::Const::EACCES|docs::2.0::api::APR::Const/C_APR__Const__EACCES_&gt;&gt;
(permission problems),
C&lt;L&lt;APR::Const::ENOENT|docs::2.0::api::APR::Const/C_APR__Const__ENOENT_&gt;&gt;
(file not found), and others. For checking such error codes, see the
documentation for, for example,
C&lt;L&lt;APR::Status::is_EACCES|docs::2.0::api::APR::Status/C_is_EACCES_&gt;&gt;
and
C&lt;L&lt;APR::Status::is_ENOENT|docs::2.0::api::APR::Status/C_is_ENOENT_&gt;&gt;.


=item since: 2.0.00

=back

Note that if you assign to C&lt;$r-E&lt;gt&gt;filename&gt; you need to L&lt;update
its stat record|docs::2.0::api::Apache2::RequestRec/C_filename_&gt;.





=head1 See Also

L&lt;mod_perl 2.0 documentation|docs::2.0::index&gt;.




=head1 Copyright

mod_perl 2.0 and its core modules are copyrighted under
The Apache Software License, Version 2.0.




=head1 Authors

L&lt;The mod_perl development team and numerous
contributors|about::contributors::people&gt;.

=cut

</pre></body></html>