home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / RequestUtil.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  22.5 KB  |  1,093 lines

  1. # /*
  2. #  * *********** WARNING **************
  3. #  * This file generated by ModPerl::WrapXS/0.01
  4. #  * Any changes made here will be lost
  5. #  * ***********************************
  6. #  * 01: lib/ModPerl/Code.pm:701
  7. #  * 02: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:584
  8. #  * 03: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:1100
  9. #  * 04: Makefile.PL:335
  10. #  * 05: Makefile.PL:283
  11. #  * 06: Makefile.PL:51
  12. #  */
  13.  
  14.  
  15. package Apache::RequestUtil;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20.  
  21.  
  22. use Apache::XSLoader ();
  23. our $VERSION = '0.01';
  24. Apache::XSLoader::load __PACKAGE__;
  25.  
  26.  
  27.  
  28. 1;
  29. __END__
  30.  
  31. =head1 NAME
  32.  
  33. Apache::RequestUtil - Perl API for Apache request record utils
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use Apache::RequestUtil ();
  41.   
  42.   # add httpd config dynamically
  43.   $r->add_config(['require valid-user']);
  44.   
  45.   # dump the request object as a string
  46.   print $r->as_string();
  47.   
  48.   # default content_type
  49.   $content_type = $r->default_type();
  50.   
  51.   # get PerlSetVar/PerlAddVar values
  52.   @values = $r->dir_config($key);
  53.   
  54.   # get server docroot
  55.   $docroot = $r->document_root();
  56.   
  57.   # what are the registered perl handlers for a given phase
  58.   my @handlers = @{ $r->get_handlers('PerlResponseHandler') || [] };
  59.   
  60.   # push a new handler for a given phase
  61.   $r->push_handlers(PerlCleanupHandler => \&handler);
  62.   
  63.   # set handlers for a given phase (resetting previous values)
  64.   $r->set_handlers(PerlCleanupHandler => []);
  65.   
  66.   # what's the request body limit
  67.   $limit = $r->get_limit_req_body();
  68.   
  69.   # server and port names
  70.   $server = $r->get_server_name();
  71.   $port   = $r->get_server_port();
  72.   
  73.   # what string Apache is going to send for a given status code
  74.   $status_line = Apache::RequestUtil::get_status_line(404);
  75.   
  76.   # are we in the main request?
  77.   $is_initial = $r->is_initial_req();
  78.   
  79.   # directory level PerlOptions flags lookup
  80.   $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');
  81.   
  82.   # current <Location> value
  83.   $location = $r->location();
  84.   
  85.   # merge a <Location> container in a request object
  86.   $r->location_merge($location);
  87.   
  88.   # create a new Apache::RequestRec object
  89.   $r = Apache::RequestRec->new($c);
  90.   
  91.   # tell the client not to cache the response
  92.   $r->no_cache($boolean);
  93.   
  94.   # share perl objects like $r->notes
  95.   $r->pnotes($key => [$obj1, $obj2]);
  96.   
  97.   # get HTML signature
  98.   $sig = $r->psignature($prefix);
  99.   
  100.   # get the global request object (requires PerlOptions +GlobalRequest)
  101.   $r = Apache->request;
  102.   
  103.   # insert auth credentials into the request as if the client did that
  104.   $r->set_basic_credentials($username, $password);
  105.   
  106.   # slurp the contents of $r->filename
  107.   my $content = ${ $r->slurp_filename() };
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. =head1 Description
  116.  
  117. C<Apache::RequestUtil> provides the L<Apache request
  118. object|docs::2.0::api::Apache::RequestRec> utilities API.
  119.  
  120.  
  121.  
  122.  
  123.  
  124. =head1 API
  125.  
  126.  
  127.  
  128.  
  129. =head2 C<add_config>
  130.  
  131. Dynamically add Apache configuration at request processing runtime:
  132.  
  133.   $r->add_config($lines);
  134.   $r->add_config($lines, $override);
  135.  
  136. =over 4
  137.  
  138. =item obj: C<$r>
  139. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  140.  
  141. =item arg1: C<$lines> (ARRAY ref)
  142.  
  143. An ARRAY reference containing configuration lines per element, without
  144. the new line terminators.
  145.  
  146. =item opt arg2: C<$override> ( C<L<APR::Const status
  147. constant|docs::2.0::api::APR::Const>> )
  148.  
  149. Which allow-override bits are set
  150.  
  151. Default value is:
  152. C<L<Apache::OR_AUTHCFG|docs::2.0::api::Apache::Const/C_Apache__OR_AUTHCFG_>>
  153.  
  154. =item ret: no return value
  155.  
  156. =item since: 1.99_10
  157.  
  158. =back
  159.  
  160. See also:
  161. C<L<$s-E<gt>add_config|docs::2.0::api::Apache::ServerUtil/C_add_config_>>
  162.  
  163. For example:
  164.  
  165.   use Apache::ServerUtil ();
  166.   $r->add_config(['require valid-user']);
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. =head2 C<as_string>
  175.  
  176. Dump the request object as a string
  177.  
  178.   $dump = $r->as_string();
  179.  
  180. =over 4
  181.  
  182. =item obj: C<$r>
  183. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  184.  
  185. =item ret: C<$dump> ( string )
  186.  
  187. =item since: 1.99_10
  188.  
  189. =back
  190.  
  191. Dumps various request and response headers (mainly useful for
  192. debugging)
  193.  
  194.  
  195.  
  196.  
  197.  
  198. =head2 C<default_type>
  199.  
  200. Retrieve the value of the DefaultType directive for the current
  201. request. If not set C<text/plain> is returned.
  202.  
  203.   $content_type = $r->default_type();
  204.  
  205. =over 4
  206.  
  207. =item obj: C<$r>
  208. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  209.  
  210. The current request
  211.  
  212. =item ret: C<$content_type> ( string )
  213.  
  214. The default type
  215.  
  216. =item since: 1.99_10
  217.  
  218. =back
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225. =head2 C<dir_config>
  226.  
  227. C<$r-E<gt>dir_config()> provides an interface for the per-directory
  228. variable specified by the C<PerlSetVar> and C<PerlAddVar> directives,
  229. and also can be manipulated via the
  230. C<L<APR::Table|docs::2.0::api::APR::Table>> methods.
  231.  
  232.   $table  = $r->dir_config();
  233.   $value  = $r->dir_config($key);
  234.   @values = $r->dir_config($key);
  235.   $r->dir_config($key, $val);
  236.  
  237. =over 4
  238.  
  239. =item obj: C<$r>
  240. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  241.  
  242. =item opt arg2: C<$key> ( string )
  243.  
  244. Key string
  245.  
  246. =item opt arg3: C<$val> ( string )
  247.  
  248. Value string
  249.  
  250. =item ret: ...
  251.  
  252. Depends on the passed arguments, see further discussion
  253.  
  254. =item since: 1.99_10
  255.  
  256. =back
  257.  
  258. The keys are case-insensitive.
  259.  
  260.   $apr_table = $r->dir_config();
  261.  
  262. dir_config() called in a scalar context without the C<$key> argument
  263. returns a I<HASH> reference blessed into the
  264. C<L<APR::Table|docs::2.0::api::APR::Table>> class. This object can be
  265. manipulated via the C<L<APR::Table|docs::2.0::api::APR::Table>>
  266. methods. For available methods see
  267. the C<L<APR::Table|docs::2.0::api::APR::Table>> manpage.
  268.  
  269.   @values = $r->dir_config($key);
  270.  
  271. If the C<$key> argument is passed in the list context a list of all
  272. matching values will be returned. This method is ineffective for big
  273. tables, as it does a linear search of the table. Thefore avoid using
  274. this way of calling dir_config() unless you know that there could be
  275. more than one value for the wanted key and all the values are wanted.
  276.  
  277.   $value = $r->dir_config($key);
  278.  
  279. If the C<$key> argument is passed in the scalar context only a single
  280. value will be returned. Since the table preserves the insertion order,
  281. if there is more than one value for the same key, the oldest value
  282. assosiated with the desired key is returned. Calling in the scalar
  283. context is also much faster, as it'll stop searching the table as soon
  284. as the first match happens.
  285.  
  286.   $r->dir_config($key => $val);
  287.  
  288. If the C<$key> and the C<$val> arguments are used, the set() operation
  289. will happen: all existing values associated with the key C<$key> (and
  290. the key itself) will be deleted and C<$value> will be placed instead.
  291.  
  292.   $r->dir_config($key => undef);
  293.  
  294. If C<$val> is I<undef> the unset() operation will happen: all existing
  295. values associated with the key C<$key> (and the key itself) will be
  296. deleted.
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304. =head2 C<document_root>
  305.  
  306. Retrieve the document root for this server
  307.  
  308.   $docroot = $r->document_root();
  309.  
  310. =over 4
  311.  
  312. =item obj: C<$r>
  313. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  314.  
  315. The current request
  316.  
  317. =item ret: C<$docroot> ( string )
  318.  
  319. The document root
  320.  
  321. =item since: 1.99_10
  322.  
  323. =back
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. =head2 C<get_handlers>
  333.  
  334. Returns a reference to a list of handlers enabled for a given phase.
  335.  
  336.   $handlers_list = $r->get_handlers($hook_name);
  337.  
  338. =over 4
  339.  
  340. =item obj: C<$r>
  341. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  342.  
  343. =item arg1: C<$hook_name> ( string )
  344.  
  345. a string representing the phase to handle (e.g. C<PerlLogHandler>)
  346.  
  347. =item ret: C<$handlers_list> (ref to an ARRAY of CODE refs)
  348.  
  349. a list of handler subroutines CODE references
  350.  
  351. =item since: 1.99_10
  352.  
  353. =back
  354.  
  355. See also:
  356. C<L<$s-E<gt>add_config|docs::2.0::api::Apache::ServerUtil/C_get_handlers_>>
  357.  
  358. For example:
  359.  
  360. A list of handlers configured to run at the response phase:
  361.  
  362.   my @handlers = @{ $r->get_handlers('PerlResponseHandler') || [] };
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370. =head2 C<get_limit_req_body>
  371.  
  372. Return the limit on bytes in request msg body
  373.  
  374.   $limit = $r->get_limit_req_body();
  375.  
  376. =over 4
  377.  
  378. =item obj: C<$r>
  379. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  380.  
  381. The current request
  382.  
  383. =item ret: C<$limit> (integer)
  384.  
  385. the maximum number of bytes in the request msg body
  386.  
  387. =item since: 1.99_10
  388.  
  389. =back
  390.  
  391.  
  392.  
  393.  
  394.  
  395. =head2 C<get_server_name>
  396.  
  397. Get the current request's server name
  398.  
  399.   $server = $r->get_server_name();
  400.  
  401. =over 4
  402.  
  403. =item obj: C<$r>
  404. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  405.  
  406. The current request
  407.  
  408. =item ret: C<$server> ( string )
  409.  
  410. the server name
  411.  
  412. =item since: 1.99_10
  413.  
  414. =back
  415.  
  416. For example, consruct a hostport string:
  417.  
  418.   use Apache::RequestUtil ();
  419.   my $hostport = join ':', $r->get_server_name, $r->get_server_port;
  420.  
  421.  
  422.  
  423.  
  424.  
  425. =head2 C<get_server_port>
  426.  
  427. Get the current server port
  428.  
  429.   $port = $r->get_server_port();
  430.  
  431. =over 4
  432.  
  433. =item obj: C<$r>
  434. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  435.  
  436. The current request
  437.  
  438. =item ret: C<$port> ( integer )
  439.  
  440. The server's port number
  441.  
  442. =item since: 1.99_10
  443.  
  444. =back
  445.  
  446. For example, consruct a hostport string:
  447.  
  448.   use Apache::RequestUtil ();
  449.   my $hostport = join ':', $r->get_server_name, $r->get_server_port;
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. =head2 C<get_status_line>
  458.  
  459. Return the C<Status-Line> for a given status code (excluding the
  460. HTTP-Version field).
  461.  
  462.   $status_line = Apache::RequestUtil::get_status_line($status);
  463.  
  464. =over 4
  465.  
  466. =item arg1: C<$status> (integer)
  467.  
  468. The HTTP status code
  469.  
  470. =item ret: C<$status_line> ( string )
  471.  
  472. The Status-Line
  473.  
  474. If an invalid or unknown status code is passed, C<"500 Internal Server
  475. Error"> will be returned.
  476.  
  477. =item since: 1.99_15
  478.  
  479. =back
  480.  
  481. For example:
  482.  
  483.   use Apache::RequestUtil ();
  484.   print Apache::RequestUtil::get_status_line(400);
  485.  
  486. will print:
  487.  
  488.   400 Bad Request
  489.  
  490.  
  491.  
  492.  
  493.  
  494. =head2 C<is_initial_req>
  495.  
  496. Determine whether the current request is the main request or a
  497. sub-request
  498.  
  499.   $is_initial = $r->is_initial_req();
  500.  
  501. =over 4
  502.  
  503. =item obj: C<$r>
  504. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  505.  
  506. A request or a sub-request object
  507.  
  508. =item ret: C<$is_initial> ( boolean )
  509.  
  510. If true -- it's the main request, otherwise it's a sub-request
  511.  
  512. =item since: 1.99_10
  513.  
  514. =back
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522. =head2 C<is_perl_option_enabled>
  523.  
  524. check whether a directory level C<PerlOptions> flag is enabled or not.
  525.  
  526.   $result = $r->is_perl_option_enabled($flag);
  527.  
  528. =over 4
  529.  
  530. =item obj: C<$r>
  531. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  532.  
  533. =item arg1: C<$flag> ( string )
  534.  
  535. =item ret: C<$result> ( boolean )
  536.  
  537. =item since: 1.99_10
  538.  
  539. =back
  540.  
  541. For example to check whether the C<SetupEnv> option is enabled for the
  542. current request (which can be disabled with C<PerlOptions -SetupEnv>)
  543. and populate the environment variables table if disabled:
  544.  
  545.   $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');
  546.  
  547. See also:
  548. L<PerlOptions|docs::2.0::user::config::config/C_PerlOptions_> and
  549. L<the equivalent function for server level PerlOptions
  550. flags|docs::2.0::api::Apache::ServerUtil/C_is_perl_option_enabled_>.
  551.  
  552.  
  553.  
  554.  
  555.  
  556. =head2 C<location>
  557.  
  558. Get the path of the E<lt>LocationE<gt> section from which the current
  559. C<Perl*Handler> is being called.
  560.  
  561.   $location = $r->location();
  562.  
  563. =over 4
  564.  
  565. =item obj: C<$r>
  566. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  567.  
  568. =item ret: C<$location> ( string )
  569.  
  570. =item since: 1.99_10
  571.  
  572. =back
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579. =head2 C<location_merge>
  580.  
  581. Merge a given C<E<lt>LocationE<lt>> container into the current request
  582. object:
  583.  
  584.   $ret = $r->location_merge($location);
  585.  
  586. =over 4
  587.  
  588. =item obj: C<$r>
  589. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  590.  
  591. =item arg1: C<$location> ( string )
  592.  
  593. The argument in a C<E<lt>LocationE<lt>> section. For example to merge
  594. a container:
  595.  
  596.   <Location /foo>
  597.       ...
  598.   </Location>
  599.  
  600. that argument will be I</foo>
  601.  
  602. =item ret: C<$ret> ( boolean )
  603.  
  604. a true value if the merge was successful (i.e. the request
  605. C<$location> match was found), otherwise false.
  606.  
  607. =item since: 1.99_10
  608.  
  609. =back
  610.  
  611. Useful for insertion of a configuration section into a custom
  612. C<Apache::RequestRec> object, created via the
  613. C<Apache::RequestRec-E<gt>new()> method. See for example the L<Command
  614. Server protocol
  615. example|docs::2.0::user::handlers::protocols/Command_Server>.
  616.  
  617.  
  618.  
  619.  
  620.  
  621. =head2 C<new>
  622.  
  623. Create a new C<Apache::RequestRec> object.
  624.  
  625.   $r = Apache::RequestRec->new($c);
  626.   $r = Apache::RequestRec->new($c, $pool);
  627.  
  628. =over 4
  629.  
  630. =item obj: C<Apache::RequestRec>
  631. ( C<L<Apache::RequestRec class name|docs::2.0::api::Apache::RequestRec>> )
  632.  
  633. =item arg1: C<$c>
  634. (C<L<Apache::Connection object|docs::2.0::api::Apache::Connection>>)
  635.  
  636. =item opt arg2: C<$pool>
  637.  
  638. If no C<$pool> argument is passed, C<$c-E<gt>pool> is used. That means
  639. that the created C<Apache::RequestRec> object will be valid as long as
  640. the connection object is valid.
  641.  
  642. =item ret: C<$r>
  643. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  644.  
  645. =item since: 1.99_10
  646.  
  647. =back
  648.  
  649. It's possible to reuse the HTTP framework features outside the
  650. familiar HTTP request cycle. It's possible to write your own full or
  651. partial HTTP implementation without needing a running Apache
  652. server. You will need the C<Apache::RequestRec> object in order to be
  653. able to reuse the rich functionality supplied via this object.
  654.  
  655. See for example the L<Command Server protocol
  656. example|docs::2.0::user::handlers::protocols/Command_Server> which
  657. reuses HTTP AAA model under non-HTTP protocol.
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. =head2 C<no_cache>
  666.  
  667. Add/remove cache control headers:
  668.  
  669.   $prev_no_cache = $r->no_cache($boolean);
  670.  
  671. =over 4
  672.  
  673. =item obj: C<$r>
  674. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  675.  
  676. =item arg1: C<$boolean> ( boolean )
  677.  
  678. A true value sets the C<no_cache> request record member to a true
  679. value and inserts:
  680.  
  681.   Pragma: no-cache
  682.   Cache-control: no-cache
  683.  
  684. into the response headers, indicating that the data being returned is
  685. volatile and the client should not cache it.
  686.  
  687. A false value unsets the C<no_cache> request record member and the
  688. mentioned headers if they were previously set.
  689.  
  690. =item ret: C<$prev_no_cache> ( boolean )
  691.  
  692. Should you care, the C<no_cache> request record member value prior to
  693. the change is returned.
  694.  
  695. =item since: 1.99_10
  696.  
  697. =back
  698.  
  699. This method should be invoked before any response data has been sent
  700. out.
  701.  
  702.  
  703.  
  704.  
  705.  
  706. =head2 C<pnotes>
  707.  
  708. Share Perl variables between Perl HTTP handlers
  709.  
  710.   $old_val  = $r->pnotes($key => $val);
  711.   $val      = $r->pnotes($key);
  712.   $hash_ref = $r->pnotes();
  713.  
  714. =over 4
  715.  
  716. =item obj: C<$r>
  717. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  718.  
  719. =item opt arg1: C<$key> ( string )
  720.  
  721. A key value
  722.  
  723. =item opt arg2: C<$val> ( SCALAR )
  724.  
  725. Any scalar value (e.g. a reference to an array)
  726.  
  727. =item ret: (3 different possible values)
  728.  
  729. if both, C<$key> and C<$val> are passed the previous value for C<$key>
  730. is returned if such existed, otherwise C<undef> is returned.
  731.  
  732. if only C<$key> is passed, the current value for the given key is
  733. returned.
  734.  
  735. if no arguments are passed, a hash reference is returned, which can
  736. then be directly accessed without going through the C<pnotes()>
  737. interface.
  738.  
  739. =item since: 1.99_10
  740.  
  741. =back
  742.  
  743. This method provides functionality similar to
  744. (C<L<Apache::RequestRec::notes|docs::2.0::api::Apache::RequestRec/C_notes_>>),
  745. but values can be any Perl variables. That also means that it can be
  746. used only between Perl modules.
  747.  
  748. The values get reset automatically at the end of each HTTP request.
  749.  
  750. Examples:
  751.  
  752. Set a key/value pair:
  753.  
  754.   $r->pnotes(foo => [1..5]);
  755.  
  756. Get the value:
  757.  
  758.   $val = $r->pnotes("foo");
  759.  
  760. C<$val> now contains an array ref containing 5 elements (C<1..5>).
  761.  
  762. Now change the existing value:
  763.  
  764.   $old_val = $r->pnotes(foo => ['a'..'c']);
  765.   $val = $r->pnotes("foo");
  766.  
  767. C<$old_val> now contains an array ref with 5 elements (C<1..5>) and
  768. C<$val> contains an array ref with 3 elements C<'a'>, C<'b'>, C<'c'>.
  769.  
  770. Alternatively you can access the hash reference with all pnotes
  771. values:
  772.  
  773.   $pnotes = $r->pnotes;
  774.  
  775. Now we can read what's in there for the key I<foo>:
  776.  
  777.   $val = $pnotes->{foo};
  778.  
  779. and as before C<$val> still gives us an array ref with 3 elements
  780. C<'a'>, C<'b'>, C<'c'>.
  781.  
  782. Now we can add elements to it:
  783.  
  784.   push @{ $pnotes{foo} }, 'd'..'f';
  785.  
  786. and we can try to retrieve them using the hash and non-hash API:
  787.  
  788.   $val1 = $pnotes{foo};
  789.   $val2 = $r->pnotes("foo");
  790.  
  791. Both C<$val1> and C<$val2> contain an array ref with 6 elements
  792. (letters 'a' to 'f').
  793.  
  794. Finally to reset an entry you could just assign C<undef> as a value:
  795.  
  796.   $r->pnotes(foo => undef);
  797.  
  798. but the entry for the key I<foo> still remains with the value
  799. C<undef>. If you really want to completely remove it, use the hash
  800. interface:
  801.  
  802.   delete $r->pnotes->{foo};
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811. =head2 C<psignature>
  812.  
  813. Get HTML describing the address and (optionally) admin of the server.
  814.  
  815.   $sig = $r->psignature($prefix);
  816.  
  817. =over 4
  818.  
  819. =item obj: C<$r>
  820. ( C<L<Apache::RequestRec|docs::2.0::api::Apache::RequestRec>> )
  821.  
  822. =item arg1: C<$prefix> ( string )
  823.  
  824. Text which is prepended to the return value
  825.  
  826. =item ret: C<$sig> ( string )
  827.  
  828. HTML text describing the server. Note that depending on the value of
  829. the C<ServerSignature> directive, the function may return the address,
  830. including the admin information or nothing at all.
  831.  
  832. =item since: 1.99_15
  833.  
  834. =back
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842. =head2 C<request>
  843.  
  844. Retrieve the ( C<L<Apache::RequestRec
  845. object|docs::2.0::api::Apache::RequestRec>> ) object for the current
  846. request.
  847.  
  848.   $r = Apache->request;
  849.  
  850. =over 4
  851.  
  852. =item obj: C<Apache> (class name)
  853.  
  854. The Apache class name
  855.  
  856. =item ret: C<$r>
  857. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  858.  
  859. =item since: 1.99_10
  860.  
  861. =back
  862.  
  863. This method is only available if C<L<PerlOptions
  864. +GlobalRequest|docs::2.0::user::config::config/C_GlobalRequest_>> is
  865. in effect.
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872. =head2 C<push_handlers>
  873.  
  874. Add one or more handlers to a list of handlers to be called for a
  875. given phase.
  876.  
  877.   $ok = $r->push_handlers($hook_name => \&handler);
  878.   $ok = $r->push_handlers($hook_name => ['Foo::Bar::handler', \&handler2]);
  879.  
  880. =over 4
  881.  
  882. =item obj: C<$r>
  883. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  884.  
  885. =item arg1: C<$hook_name> ( string )
  886.  
  887. the phase to add the handlers to
  888.  
  889. =item arg2: C<$handlers> ( CODE ref or SUB name or an ARRAY ref )
  890.  
  891. a single handler CODE reference or just a name of the subroutine
  892. (fully qualified unless defined in the current package).
  893.  
  894. if more than one passed, use a reference to an array of CODE refs
  895. and/or subroutine names.
  896.  
  897. =item ret: C<$ok> ( boolean )
  898.  
  899. returns a true value on success, otherwise a false value
  900.  
  901. =item since: 1.99_10
  902.  
  903. See also:
  904. C<L<$s-E<gt>add_config|docs::2.0::api::Apache::ServerUtil/C_push_handlers_>>
  905.  
  906. =back
  907.  
  908. Examples:
  909.  
  910. A single handler:
  911.  
  912.   $r->push_handlers(PerlResponseHandler => \&handler);
  913.  
  914. Multiple handlers:
  915.  
  916.   $r->push_handlers(PerlFixupHandler => ['Foo::Bar::handler', \&handler2]);
  917.  
  918. Anonymous functions:
  919.  
  920.   $r->push_handlers(PerlLogHandler => sub { return Apache::OK });
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927. =head2 C<set_basic_credentials>
  928.  
  929. Populate the incoming request headers table (C<headers_in>) with
  930. authentication headers for Basic Authorization as if the client has
  931. submitted those in first place:
  932.  
  933.   $r->set_basic_credentials($username, $password);
  934.  
  935. =over 4
  936.  
  937. =item obj: C<$r>
  938. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  939.  
  940. =item arg1: C<$username> ( string )
  941.  
  942. =item arg2: C<$password> ( string )
  943.  
  944. =item ret: no return value
  945.  
  946. =item since: 1.99_10
  947.  
  948. =back
  949.  
  950. See for example the L<Command Server protocol
  951. example|docs::2.0::user::handlers::protocols/Command_Server> which
  952. reuses HTTP AAA model under non-HTTP protocol.
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960. =head2 C<set_handlers>
  961.  
  962. Set a list of handlers to be called for a given phase. Any previously
  963. set handlers are forgotten.
  964.  
  965.   $ok = $r->set_handlers($hook_name => \&handler);
  966.   $ok = $r->set_handlers($hook_name => ['Foo::Bar::handler', \&handler2]);
  967.   $ok = $r->set_handlers($hook_name => []);
  968.   $ok = $r->set_handlers($hook_name => undef);
  969.  
  970. =over 4
  971.  
  972. =item obj: C<$r>
  973. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  974.  
  975. =item arg1: C<$hook_name> ( string )
  976.  
  977. the phase to set the handlers in
  978.  
  979. =item arg2: C<$handlers> (CODE ref or SUB name or an ARRAY ref)
  980.  
  981. a reference to a single handler CODE reference or just a name of the
  982. subroutine (fully qualified unless defined in the current package).
  983.  
  984. if more than one passed, use a reference to an array of CODE refs
  985. and/or subroutine names.
  986.  
  987. if the argument is C<undef> or C<[]> the list of handlers is reset to
  988. zero.
  989.  
  990. =item ret: C<$ok> ( boolean )
  991.  
  992. returns a true value on success, otherwise a false value
  993.  
  994. =item since: 1.99_10
  995.  
  996. =back
  997.  
  998. See also:
  999. C<L<$s-E<gt>add_config|docs::2.0::api::Apache::ServerUtil/C_set_handlers_>>
  1000.  
  1001. Examples:
  1002.  
  1003. A single handler:
  1004.  
  1005.   $r->set_handlers(PerlResponseHandler => \&handler);
  1006.  
  1007. Multiple handlers:
  1008.  
  1009.   $r->set_handlers(PerlFixupHandler => ['Foo::Bar::handler', \&handler2]);
  1010.  
  1011. Anonymous functions:
  1012.  
  1013.   $r->set_handlers(PerlLogHandler => sub { return Apache::OK });
  1014.  
  1015. Reset any previously set handlers:
  1016.  
  1017.   $r->set_handlers(PerlCleanupHandler => []);
  1018.  
  1019. or
  1020.  
  1021.   $r->set_handlers(PerlCleanupHandler => undef);
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029. =head2 C<slurp_filename>
  1030.  
  1031. Slurp the contents of C<$r-E<gt>filename>:
  1032.  
  1033.   $content_ref = $r->slurp_filename($tainted);
  1034.  
  1035. =over 4
  1036.  
  1037. =item obj: C<$r>
  1038. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1039.  
  1040. =item arg1: C<$tainted> (number)
  1041.  
  1042. If the server is run under the tainting mode (C<-T>) which we hope you
  1043. do, by default the returned data is tainted. If an optional
  1044. C<$tainted> flag is set to zero, the data will be marked as
  1045. non-tainted.
  1046.  
  1047. Do B<not> set this flag to zero unless you know what you are doing,
  1048. you may create a security hole in your program if you do. For more
  1049. information see the I<perlsec> manpage.
  1050.  
  1051. If you wonder why this option is available, it is used internally by
  1052. the C<L<ModPerl::Registry|docs::2.0::api::ModPerl::Registry>> handler
  1053. and friends, because the CGI scripts that it reads are considered safe
  1054. (you could just as well C<require()> them).
  1055.  
  1056. =item ret: C<$content_ref> ( SCALAR ref )
  1057.  
  1058. A reference to a string with the contents
  1059.  
  1060. =item since: 1.99_10
  1061.  
  1062. =back
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069. =head1 See Also
  1070.  
  1071. L<mod_perl 2.0 documentation|docs::2.0::index>.
  1072.  
  1073.  
  1074.  
  1075.  
  1076. =head1 Copyright
  1077.  
  1078. mod_perl 2.0 and its core modules are copyrighted under
  1079. The Apache Software License, Version 2.0.
  1080.  
  1081.  
  1082.  
  1083.  
  1084. =head1 Authors
  1085.  
  1086. L<The mod_perl development team and numerous
  1087. contributors|about::contributors::people>.
  1088.  
  1089. =cut
  1090.  
  1091.