.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "libapache2-mod-perl2-2.0.11::docs::api::Apache2::SubRequest 3pm" .TH libapache2-mod-perl2-2.0.11::docs::api::Apache2::SubRequest 3pm "2021-05-21" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Apache2::SubRequest \- Perl API for Apache subrequests .SH "Synopsis" .IX Header "Synopsis" .Vb 1 \& use Apache2::SubRequest (); \& \& # run internal redirects at once \& $r\->internal_redirect($new_uri); \& $r\->internal_redirect_handler($new_uri); \& \& # create internal redirect objects \& $subr = $r\->lookup_uri("/foo"); \& $subr = $r\->lookup_method_uri("GET", "/tmp/bar") \& $subr = $r\->lookup_file("/tmp/bar"); \& # optionally manipulate the output through main request filters \& $subr = $r\->lookup_uri("/foo", $r\->output_filters); \& # now run them \& my $rc = $subr\->run; .Ve .SH "Description" .IX Header "Description" \&\f(CW\*(C`Apache2::SubRequest\*(C'\fR contains \s-1API\s0 for creating and running of Apache sub-requests. .PP \&\f(CW\*(C`Apache2::SubRequest\*(C'\fR is a sub-class of \f(CW\*(C`Apache2::RequestRec object\*(C'\fR. .SH "API" .IX Header "API" \&\f(CW\*(C`Apache2::SubRequest\*(C'\fR provides the following functions and/or methods: .ie n .SS """DESTROY""" .el .SS "\f(CWDESTROY\fP" .IX Subsection "DESTROY" Free the memory associated with a sub request: .PP .Vb 1 \& undef $subr; # but normally don\*(Aqt do that .Ve .ie n .IP "obj: $subr ( ""Apache2::SubRequest object"" )" 4 .el .IP "obj: \f(CW$subr\fR ( \f(CWApache2::SubRequest object\fR )" 4 .IX Item "obj: $subr ( Apache2::SubRequest object )" The sub request to finish .IP "ret: no return value" 4 .IX Item "ret: no return value" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP \&\f(CW\*(C`DESTROY\*(C'\fR is called automatically when \f(CW$subr\fR goes out of scope. .PP If you want to free the memory earlier than that (for example if you run several subrequests), you can \f(CW\*(C`undef\*(C'\fR the object as: .PP .Vb 1 \& undef $subr; .Ve .PP but never call \f(CW\*(C`DESTROY\*(C'\fR explicitly, since it'll result in \&\f(CW\*(C`ap_destroy_sub_req\*(C'\fR being called more than once, resulting in multiple brain injuries and certain hair loss. .ie n .SS """internal_redirect""" .el .SS "\f(CWinternal_redirect\fP" .IX Subsection "internal_redirect" Redirect the current request to some other uri internally .PP .Vb 1 \& $r\->internal_redirect($new_uri); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $new_uri ( string )" 4 .el .IP "arg1: \f(CW$new_uri\fR ( string )" 4 .IX Item "arg1: $new_uri ( string )" The \s-1URI\s0 to replace the current request with .IP "ret: no return value" 4 .IX Item "ret: no return value" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP In case that you want some other request to be served as the top-level request instead of what the client requested directly, call this method from a handler, and then immediately return \f(CW\*(C`Apache2::Const::OK\*(C'\fR. The client will be unaware the a different request was served to her behind the scenes. .ie n .SS """internal_redirect_handler""" .el .SS "\f(CWinternal_redirect_handler\fP" .IX Subsection "internal_redirect_handler" Identical to \f(CW\*(C`internal_redirect\*(C'\fR, plus automatically sets \&\f(CW\*(C`$r\->content_type\*(C'\fR is of the sub-request to be the same as of the main request, if \&\f(CW\*(C`$r\->handler\*(C'\fR is true. .PP .Vb 1 \& $r\->internal_redirect_handler($new_uri); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $new_uri ( string )" 4 .el .IP "arg1: \f(CW$new_uri\fR ( string )" 4 .IX Item "arg1: $new_uri ( string )" The \s-1URI\s0 to replace the current request with. .IP "ret: no return value" 4 .IX Item "ret: no return value" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This function is designed for things like actions or \s-1CGI\s0 scripts, when using \f(CW\*(C`AddHandler\*(C'\fR, and you want to preserve the content type across an internal redirect. .ie n .SS """lookup_file""" .el .SS "\f(CWlookup_file\fP" .IX Subsection "lookup_file" Create a subrequest for the given file. This sub request can be inspected to find information about the requested file .PP .Vb 2 \& $ret = $r\->lookup_file($new_file); \& $ret = $r\->lookup_file($new_file, $next_filter); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $new_file ( string )" 4 .el .IP "arg1: \f(CW$new_file\fR ( string )" 4 .IX Item "arg1: $new_file ( string )" The file to lookup .ie n .IP "opt arg2: $next_filter ( ""Apache2::Filter"" )" 4 .el .IP "opt arg2: \f(CW$next_filter\fR ( \f(CWApache2::Filter\fR )" 4 .IX Item "opt arg2: $next_filter ( Apache2::Filter )" See \f(CW\*(C`$r\->lookup_uri\*(C'\fR for details. .ie n .IP "ret: $ret ( ""Apache2::SubRequest object"" )" 4 .el .IP "ret: \f(CW$ret\fR ( \f(CWApache2::SubRequest object\fR )" 4 .IX Item "ret: $ret ( Apache2::SubRequest object )" The sub request record. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP See \f(CW\*(C`$r\->lookup_uri\*(C'\fR for further discussion. .ie n .SS """lookup_method_uri""" .el .SS "\f(CWlookup_method_uri\fP" .IX Subsection "lookup_method_uri" Create a sub request for the given \s-1URI\s0 using a specific method. This sub request can be inspected to find information about the requested \&\s-1URI\s0 .PP .Vb 2 \& $ret = $r\->lookup_method_uri($method, $new_uri); \& $ret = $r\->lookup_method_uri($method, $new_uri, $next_filter); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $method ( string )" 4 .el .IP "arg1: \f(CW$method\fR ( string )" 4 .IX Item "arg1: $method ( string )" The method to use in the new sub request (e.g. \f(CW"GET"\fR) .ie n .IP "arg2: $new_uri ( string )" 4 .el .IP "arg2: \f(CW$new_uri\fR ( string )" 4 .IX Item "arg2: $new_uri ( string )" The \s-1URI\s0 to lookup .ie n .IP "opt arg3: $next_filter ( ""Apache2::Filter object"" )" 4 .el .IP "opt arg3: \f(CW$next_filter\fR ( \f(CWApache2::Filter object\fR )" 4 .IX Item "opt arg3: $next_filter ( Apache2::Filter object )" See \f(CW\*(C`$r\->lookup_uri\*(C'\fR for details. .ie n .IP "ret: $ret ( ""Apache2::SubRequest object"" )" 4 .el .IP "ret: \f(CW$ret\fR ( \f(CWApache2::SubRequest object\fR )" 4 .IX Item "ret: $ret ( Apache2::SubRequest object )" The sub request record. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP See \f(CW\*(C`$r\->lookup_uri\*(C'\fR for further discussion. .ie n .SS """lookup_uri""" .el .SS "\f(CWlookup_uri\fP" .IX Subsection "lookup_uri" Create a sub request from the given \s-1URI.\s0 This sub request can be inspected to find information about the requested \s-1URI.\s0 .PP .Vb 2 \& $ret = $r\->lookup_uri($new_uri); \& $ret = $r\->lookup_uri($new_uri, $next_filter); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $new_uri ( string )" 4 .el .IP "arg1: \f(CW$new_uri\fR ( string )" 4 .IX Item "arg1: $new_uri ( string )" The \s-1URI\s0 to lookup .ie n .IP "opt arg2: $next_filter ( ""Apache2::Filter object"" )" 4 .el .IP "opt arg2: \f(CW$next_filter\fR ( \f(CWApache2::Filter object\fR )" 4 .IX Item "opt arg2: $next_filter ( Apache2::Filter object )" The first filter the subrequest should pass the data through. If not specified it defaults to the first connection output filter for the main request \&\f(CW\*(C`$r\->proto_output_filters\*(C'\fR. So if the subrequest sends any output it will be filtered only once. If for example you desire to apply the main request's output filters to the sub-request output as well pass \&\f(CW\*(C`$r\->output_filters\*(C'\fR as an argument. .ie n .IP "ret: $ret ( ""Apache2::SubRequest object"" )" 4 .el .IP "ret: \f(CW$ret\fR ( \f(CWApache2::SubRequest object\fR )" 4 .IX Item "ret: $ret ( Apache2::SubRequest object )" The sub request record .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP Here is an example of a simple subrequest which serves uri \&\fI/new_uri\fR: .PP .Vb 2 \& sub handler { \& my $r = shift; \& \& my $subr = $r\->lookup_uri("/new_uri"); \& $subr\->run; \& \& return Apache2::Const::OK; \& } .Ve .PP If let's say you have three request output filters registered to run for the main request: .PP .Vb 3 \& PerlOutputFilterHandler MyApache2::SubReqExample::filterA \& PerlOutputFilterHandler MyApache2::SubReqExample::filterB \& PerlOutputFilterHandler MyApache2::SubReqExample::filterC .Ve .PP and you wish to run them all, the code needs to become: .PP .Vb 1 \& my $subr = $r\->lookup_uri("/new_uri", $r\->output_filters); .Ve .PP and if you wish to run them all, but the first one (\f(CW\*(C`filterA\*(C'\fR), the code needs to be adjusted to be: .PP .Vb 1 \& my $subr = $r\->lookup_uri("/new_uri", $r\->output_filters\->next); .Ve .ie n .SS """run""" .el .SS "\f(CWrun\fP" .IX Subsection "run" Run a sub-request .PP .Vb 1 \& $rc = $subr\->run(); .Ve .ie n .IP "obj: $subr ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$subr\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $subr ( Apache2::RequestRec object )" The sub-request (e.g. returned by \f(CW\*(C`lookup_uri\*(C'\fR) .ie n .IP "ret: $rc ( integer )" 4 .el .IP "ret: \f(CW$rc\fR ( integer )" 4 .IX Item "ret: $rc ( integer )" The return code of the handler (\f(CW\*(C`Apache2::Const::OK\*(C'\fR, \f(CW\*(C`Apache2::Const::DECLINED\*(C'\fR, etc.) .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .SH "Unsupported API" .IX Header "Unsupported API" \&\f(CW\*(C`Apache2::SubRequest\*(C'\fR also provides auto-generated Perl interface for a few other methods which aren't tested at the moment and therefore their \s-1API\s0 is a subject to change. These methods will be finalized later as a need arises. If you want to rely on any of the following methods please contact the the mod_perl development mailing list so we can help each other take the steps necessary to shift the method to an officially supported \s-1API.\s0 .ie n .SS """internal_fast_redirect""" .el .SS "\f(CWinternal_fast_redirect\fP" .IX Subsection "internal_fast_redirect" \&\s-1META:\s0 Autogenerated \- needs to be reviewed/completed .PP Redirect the current request to a sub_req, merging the pools .PP .Vb 1 \& $r\->internal_fast_redirect($sub_req); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $sub_req ( string )" 4 .el .IP "arg1: \f(CW$sub_req\fR ( string )" 4 .IX Item "arg1: $sub_req ( string )" A subrequest created from this request .IP "ret: no return value" 4 .IX Item "ret: no return value" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP \&\s-1META:\s0 httpd\-2.0/modules/http/http_request.c declares this function as: .PP .Vb 1 \& /* XXX: Is this function is so bogus and fragile that we deep\-6 it? */ .Ve .PP do we really want to expose it to mod_perl users? .ie n .SS """lookup_dirent""" .el .SS "\f(CWlookup_dirent\fP" .IX Subsection "lookup_dirent" \&\s-1META:\s0 Autogenerated \- needs to be reviewed/completed .PP Create a sub request for the given apr_dir_read result. This sub request can be inspected to find information about the requested file .PP .Vb 3 \& $lr = $r\->lookup_dirent($finfo); \& $lr = $r\->lookup_dirent($finfo, $subtype); \& $lr = $r\->lookup_dirent($finfo, $subtype, $next_filter); .Ve .ie n .IP "obj: $r ( ""Apache2::RequestRec object"" )" 4 .el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "obj: $r ( Apache2::RequestRec object )" The current request .ie n .IP "arg1: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "arg1: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "arg1: $finfo ( APR::Finfo object )" The apr_dir_read result to lookup .ie n .IP "arg2: $subtype ( integer )" 4 .el .IP "arg2: \f(CW$subtype\fR ( integer )" 4 .IX Item "arg2: $subtype ( integer )" What type of subrequest to perform, one of; .Sp .Vb 2 \& Apache2::SUBREQ_NO_ARGS ignore r\->args and r\->path_info \& Apache2::SUBREQ_MERGE_ARGS merge r\->args and r\->path_info .Ve .ie n .IP "arg3: $next_filter ( integer )" 4 .el .IP "arg3: \f(CW$next_filter\fR ( integer )" 4 .IX Item "arg3: $next_filter ( integer )" The first filter the sub_request should use. If this is \&\s-1NULL,\s0 it defaults to the first filter for the main request .ie n .IP "ret: $lr ( ""Apache2::RequestRec object"" )" 4 .el .IP "ret: \f(CW$lr\fR ( \f(CWApache2::RequestRec object\fR )" 4 .IX Item "ret: $lr ( Apache2::RequestRec object )" The new request record .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP \&\s-1META:\s0 where do we take the apr_dir_read result from? .SH "See Also" .IX Header "See Also" mod_perl 2.0 documentation. .SH "Copyright" .IX Header "Copyright" mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. .SH "Authors" .IX Header "Authors" The mod_perl development team and numerous contributors.