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 / SubRequest.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  10.5 KB  |  503 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::SubRequest;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20. @Apache::SubRequest::ISA = 'Apache::RequestRec';
  21.  
  22.  
  23. use Apache::XSLoader ();
  24. our $VERSION = '0.01';
  25. Apache::XSLoader::load __PACKAGE__;
  26.  
  27.  
  28.  
  29. 1;
  30. __END__
  31.  
  32. =head1 NAME
  33.  
  34. Apache::SubRequest - Perl API for Apache subrequests
  35.  
  36.  
  37.  
  38.  
  39. =head1 Synopsis
  40.  
  41.   use Apache::SubRequest ();
  42.   
  43.   # run internal redirects at once
  44.   $r->internal_redirect($new_uri);
  45.   $r->internal_redirect_handler($new_uri);
  46.   
  47.   # create internal redirect objects
  48.   $subr = $r->lookup_uri("/foo");
  49.   $subr = $r->lookup_method_uri("GET", "/tmp/bar")
  50.   $subr = $r->lookup_file("/tmp/bar");
  51.   # optionally manipulate the output through main request filters
  52.   $subr = $r->lookup_uri("/foo", $r->output_filters);
  53.   # now run them
  54.   my $rc = $subr->run;
  55.   # optional
  56.   $subr->DESTROY;
  57.  
  58.  
  59.  
  60.  
  61. =head1 Description
  62.  
  63. C<Apache::SubRequest> contains API for creating and running of Apache
  64. sub-requests.
  65.  
  66. C<Apache::SubRequest> is a sub-class of C<L<Apache::RequestRec
  67. object|docs::2.0::api::Apache::RequestRec>>.
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. =head1 API
  76.  
  77. C<Apache::SubRequest> provides the following functions and/or methods:
  78.  
  79.  
  80.  
  81.  
  82.  
  83. =head2 C<DESTROY>
  84.  
  85. Free the memory associated with a sub request
  86.  
  87.   $subr->DESTROY();
  88.  
  89. =over 4
  90.  
  91. =item obj: C<$subr> ( C<L<Apache::SubRequest
  92. object|docs::2.0::api::Apache::SubRequest/Description>> )
  93.  
  94. The sub request to finish
  95.  
  96. =item ret: no return value
  97.  
  98. =item since: 1.99_12
  99.  
  100. =back
  101.  
  102. This method will be called automatically when C<$subr> goes out of
  103. scope, so there is no need to call it explicitly, unless you want to
  104. free the memory earlier than that (for example if you run several
  105. subrequests).
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. =head2 C<internal_redirect>
  119.  
  120. Redirect the current request to some other uri internally
  121.  
  122.   $r->internal_redirect($new_uri);
  123.  
  124. =over 4
  125.  
  126. =item obj: C<$r>
  127. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  128.  
  129. The current request
  130.  
  131. =item arg1: C<$new_uri> ( string )
  132.  
  133. The URI to replace the current request with
  134.  
  135. =item ret: no return value
  136.  
  137. =item since: 1.99_12
  138.  
  139. =back
  140.  
  141. In case that you want some other request to be served as the top-level
  142. request instead of what the client requested directly, call this
  143. method from a handler, and then immediately return C<Apache::OK>. The
  144. client will be unaware the a different request was served to her
  145. behind the scenes.
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154. =head2 C<internal_redirect_handler>
  155.  
  156. Identical to C<internal_redirect|/C_internal_redirect_>, plus
  157. automatically sets
  158. C<L<$r-E<gt>content_type|docs::2.0::api::Apache::RequestRec/C_content_type_>>
  159. is of the sub-request to be the same as of the main request, if
  160. C<L<$r-E<gt>handler|docs::2.0::api::Apache::RequestRec/C_handler_>> is
  161. true.
  162.  
  163.   $r->internal_redirect_handler($new_uri);
  164.  
  165. =over 4
  166.  
  167. =item obj: C<$r>
  168. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  169.  
  170. The current request
  171.  
  172. =item arg1: C<$new_uri> ( string )
  173.  
  174. The URI to replace the current request with.
  175.  
  176. =item ret: no return value
  177.  
  178. =item since: 1.99_12
  179.  
  180. =back
  181.  
  182. This function is designed for things like actions or CGI scripts, when
  183. using C<AddHandler>, and you want to preserve the content type across
  184. an internal redirect.
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. =head2 C<lookup_file>
  196.  
  197. Create a subrequest for the given file.  This sub request can be
  198. inspected to find information about the requested file
  199.  
  200.   $ret = $r->lookup_file($new_file);
  201.   $ret = $r->lookup_file($new_file, $next_filter);
  202.  
  203. =over 4
  204.  
  205. =item obj: C<$r>
  206. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  207.  
  208. The current request
  209.  
  210. =item arg1: C<$new_file> ( string )
  211.  
  212. The file to lookup
  213.  
  214. =item opt arg2: C<$next_filter>
  215. ( C<L<Apache::Filter|docs::2.0::api::Apache::Filter>> )
  216.  
  217. See C<L<$r-E<gt>lookup_uri|/C_lookup_uri_>> for details.
  218.  
  219. =item ret: C<$ret> ( C<L<Apache::SubRequest
  220. object|docs::2.0::api::Apache::SubRequest/Description>> )
  221.  
  222. The sub request record.
  223.  
  224. =item since: 1.99_15
  225.  
  226. =back
  227.  
  228. See C<L<$r-E<gt>lookup_uri|/C_lookup_uri_>> for further discussion.
  229.  
  230.  
  231.  
  232.  
  233. =head2 C<lookup_method_uri>
  234.  
  235. Create a sub request for the given URI using a specific method.  This
  236. sub request can be inspected to find information about the requested
  237. URI
  238.  
  239.   $ret = $r->lookup_method_uri($method, $new_uri);
  240.   $ret = $r->lookup_method_uri($method, $new_uri, $next_filter);
  241.  
  242. =over 4
  243.  
  244. =item obj: C<$r>
  245. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  246.  
  247. The current request
  248.  
  249. =item arg1: C<$method> ( string )
  250.  
  251. The method to use in the new sub request (e.g. C<"GET">)
  252.  
  253. =item arg2: C<$new_uri> ( string )
  254.  
  255. The URI to lookup
  256.  
  257. =item opt arg3: C<$next_filter>
  258. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  259.  
  260. See C<L<$r-E<gt>lookup_uri|/C_lookup_uri_>> for details.
  261.  
  262. =item ret: C<$ret> ( C<L<Apache::SubRequest
  263. object|docs::2.0::api::Apache::SubRequest/Description>> )
  264.  
  265. The sub request record.
  266.  
  267. =item since: 1.99_15
  268.  
  269. =back
  270.  
  271. See C<L<$r-E<gt>lookup_uri|/C_lookup_uri_>> for further discussion.
  272.  
  273.  
  274.  
  275.  
  276.  
  277. =head2 C<lookup_uri>
  278.  
  279. Create a sub request from the given URI.  This sub request can be
  280. inspected to find information about the requested URI.
  281.  
  282.   $ret = $r->lookup_uri($new_uri);
  283.   $ret = $r->lookup_uri($new_uri, $next_filter);
  284.  
  285. =over 4
  286.  
  287. =item obj: C<$r>
  288. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  289.  
  290. The current request
  291.  
  292. =item arg1: C<$new_uri> ( string )
  293.  
  294. The URI to lookup
  295.  
  296. =item opt arg2: C<$next_filter>
  297. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  298.  
  299. The first filter the subrequest should pass the data through.  If not
  300. specified it defaults to the first connection output filter for the
  301. main request
  302. C<L<$r-E<gt>proto_output_filters|docs::2.0::api::Apache::RequestRec/C_proto_output_filters_>>. So
  303. if the subrequest sends any output it will be filtered only once. If
  304. for example you desire to apply the main request's output filters to
  305. the sub-request output as well pass
  306. C<L<$r-E<gt>output_filters|docs::2.0::api::Apache::RequestRec/C_output_filters_>>
  307. as an argument.
  308.  
  309. =item ret: C<$ret> ( C<L<Apache::SubRequest
  310. object|docs::2.0::api::Apache::SubRequest/Description>> )
  311.  
  312. The sub request record
  313.  
  314. =item since: 1.99_15
  315.  
  316. =back
  317.  
  318. Here is an example of a simple subrequest which serves uri
  319. I</new_uri>:
  320.  
  321.   sub handler {
  322.       my $r = shift;
  323.   
  324.       my $subr = $r->lookup_uri("/new_uri");
  325.       $sub->run;
  326.   
  327.       return Apache::OK;
  328.   }
  329.  
  330. If let's say you have three request output filters registered to run
  331. for the main request:
  332.  
  333.   PerlOutputFilterHandler MyApache::SubReqExample::filterA
  334.   PerlOutputFilterHandler MyApache::SubReqExample::filterB
  335.   PerlOutputFilterHandler MyApache::SubReqExample::filterC
  336.  
  337. and you wish to run them all, the code needs to become:
  338.  
  339.       my $subr = $r->lookup_uri("/new_uri", $r->output_filters);
  340.  
  341. and if you wish to run them all, but the first one (C<filterA>), the
  342. code needs to be adjusted to be:
  343.  
  344.       my $subr = $r->lookup_uri("/new_uri", $r->output_filters->next);
  345.  
  346.  
  347.  
  348.  
  349.  
  350. =head2 C<run>
  351.  
  352. Run a sub-request
  353.  
  354.   $rc = $subr->run();
  355.  
  356. =over 4
  357.  
  358. =item obj: C<$subr>
  359. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  360.  
  361. The sub-request (e.g. returned by C<L<lookup_uri|/C_lookup_uri_>>)
  362.  
  363. =item ret: C<$rc> ( integer )
  364.  
  365. The return code of the handler (C<Apache::OK>, C<Apache::DECLINED>,
  366. etc.)
  367.  
  368. =item since: 1.99_12
  369.  
  370. =back
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377. =head1 Unsupported API
  378.  
  379. C<Apache::SubRequest> also provides auto-generated Perl interface for
  380. a few other methods which aren't tested at the moment and therefore
  381. their API is a subject to change. These methods will be finalized
  382. later as a need arises. If you want to rely on any of the following
  383. methods please contact the L<the mod_perl development mailing
  384. list|maillist::dev> so we can help each other take the steps necessary
  385. to shift the method to an officially supported API.
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392. =head2 C<internal_fast_redirect>
  393.  
  394. META: Autogenerated - needs to be reviewed/completed
  395.  
  396. Redirect the current request to a sub_req, merging the pools
  397.  
  398.   $r->internal_fast_redirect($sub_req);
  399.  
  400. =over 4
  401.  
  402. =item obj: C<$r>
  403. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  404.  
  405. The current request
  406.  
  407. =item arg1: C<$sub_req> ( string )
  408.  
  409. A subrequest created from this request
  410.  
  411. =item ret: no return value
  412.  
  413. =item since: 1.99_12
  414.  
  415. =back
  416.  
  417.  
  418. META: httpd-2.0/modules/http/http_request.c declares this function as:
  419.  
  420.   /* XXX: Is this function is so bogus and fragile that we deep-6 it? */
  421.  
  422. do we really want to expose it to mod_perl users?
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429. =head2 C<lookup_dirent>
  430.  
  431. META: Autogenerated - needs to be reviewed/completed
  432.  
  433. Create a sub request for the given apr_dir_read result.  This sub request
  434. can be inspected to find information about the requested file
  435.  
  436.   $lr = $r->lookup_dirent($finfo);
  437.   $lr = $r->lookup_dirent($finfo, $subtype);
  438.   $lr = $r->lookup_dirent($finfo, $subtype, $next_filter);
  439.  
  440. =over 4
  441.  
  442. =item obj: C<$r>
  443. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  444.  
  445. The current request
  446.  
  447. =item arg1: C<$finfo>
  448. ( C<L<APR::Finfo object|docs::2.0::api::APR::Finfo>> )
  449.  
  450. The apr_dir_read result to lookup
  451.  
  452. =item arg2: C<$subtype> ( integer )
  453.  
  454. What type of subrequest to perform, one of;
  455.  
  456.   Apache::SUBREQ_NO_ARGS     ignore r->args and r->path_info
  457.   Apache::SUBREQ_MERGE_ARGS  merge  r->args and r->path_info
  458.  
  459. =item arg3: C<$next_filter> ( integer )
  460.  
  461. The first filter the sub_request should use.  If this is
  462. NULL, it defaults to the first filter for the main request
  463.  
  464. =item ret: C<$lr>
  465. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  466.  
  467. The new request record
  468.  
  469. =item since: 1.99_12
  470.  
  471. =back
  472.  
  473. META: where do we take the apr_dir_read result from?
  474.  
  475.  
  476.  
  477.  
  478.  
  479. =head1 See Also
  480.  
  481. L<mod_perl 2.0 documentation|docs::2.0::index>.
  482.  
  483.  
  484.  
  485.  
  486. =head1 Copyright
  487.  
  488. mod_perl 2.0 and its core modules are copyrighted under
  489. The Apache Software License, Version 2.0.
  490.  
  491.  
  492.  
  493.  
  494. =head1 Authors
  495.  
  496. L<The mod_perl development team and numerous
  497. contributors|about::contributors::people>.
  498.  
  499. =cut
  500.  
  501.