/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/Apache2/SubRequest.html is in libapache2-mod-perl2-doc 2.0.8+httpd24-r1449661-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#Synopsis">Synopsis</a></li>
<li><a href="#Description">Description</a></li>
<li><a href="#API">API</a>
<ul>
<li><a href="#DESTROY">DESTROY</a></li>
<li><a href="#internal_redirect">internal_redirect</a></li>
<li><a href="#internal_redirect_handler">internal_redirect_handler</a></li>
<li><a href="#lookup_file">lookup_file</a></li>
<li><a href="#lookup_method_uri">lookup_method_uri</a></li>
<li><a href="#lookup_uri">lookup_uri</a></li>
<li><a href="#run">run</a></li>
</ul>
</li>
<li><a href="#Unsupported-API">Unsupported API</a>
<ul>
<li><a href="#internal_fast_redirect">internal_fast_redirect</a></li>
<li><a href="#lookup_dirent">lookup_dirent</a></li>
</ul>
</li>
<li><a href="#See-Also">See Also</a></li>
<li><a href="#Copyright">Copyright</a></li>
<li><a href="#Authors">Authors</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>Apache2::SubRequest - Perl API for Apache subrequests</p>
<h1 id="Synopsis">Synopsis</h1>
<pre><code> 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;</code></pre>
<h1 id="Description">Description</h1>
<p><code>Apache2::SubRequest</code> contains API for creating and running of Apache sub-requests.</p>
<p><code>Apache2::SubRequest</code> is a sub-class of <code><a>Apache2::RequestRec object</a></code>.</p>
<h1 id="API">API</h1>
<p><code>Apache2::SubRequest</code> provides the following functions and/or methods:</p>
<h2 id="DESTROY"><code>DESTROY</code></h2>
<p>Free the memory associated with a sub request:</p>
<pre><code> undef $subr; # but normally don't do that</code></pre>
<dl>
<dt id="obj:-subr-Apache2::SubRequest-object">obj: <code>$subr</code> ( <code><a>Apache2::SubRequest object</a></code> )</dt>
<dd>
<p>The sub request to finish</p>
</dd>
<dt id="ret:-no-return-value">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.00">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p><code>DESTROY</code> is called automatically when <code>$subr</code> goes out of scope.</p>
<p>If you want to free the memory earlier than that (for example if you run several subrequests), you can <code>undef</code> the object as:</p>
<pre><code> undef $subr;</code></pre>
<p>but never call <code>DESTROY</code> explicitly, since it'll result in <code>ap_destroy_sub_req</code> being called more than once, resulting in multiple brain injuries and certain hair loss.</p>
<h2 id="internal_redirect"><code>internal_redirect</code></h2>
<p>Redirect the current request to some other uri internally</p>
<pre><code> $r->internal_redirect($new_uri);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-new_uri-string">arg1: <code>$new_uri</code> ( string )</dt>
<dd>
<p>The URI to replace the current request with</p>
</dd>
<dt id="ret:-no-return-value1">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.001">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>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 <code>Apache2::Const::OK</code>. The client will be unaware the a different request was served to her behind the scenes.</p>
<h2 id="internal_redirect_handler"><code>internal_redirect_handler</code></h2>
<p>Identical to <code><a href="#C_internal_redirect_">internal_redirect</a></code>, plus automatically sets <code><a>$r->content_type</a></code> is of the sub-request to be the same as of the main request, if <code><a>$r->handler</a></code> is true.</p>
<pre><code> $r->internal_redirect_handler($new_uri);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object1">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-new_uri-string1">arg1: <code>$new_uri</code> ( string )</dt>
<dd>
<p>The URI to replace the current request with.</p>
</dd>
<dt id="ret:-no-return-value2">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.002">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>This function is designed for things like actions or CGI scripts, when using <code>AddHandler</code>, and you want to preserve the content type across an internal redirect.</p>
<h2 id="lookup_file"><code>lookup_file</code></h2>
<p>Create a subrequest for the given file. This sub request can be inspected to find information about the requested file</p>
<pre><code> $ret = $r->lookup_file($new_file);
$ret = $r->lookup_file($new_file, $next_filter);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object2">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-new_file-string">arg1: <code>$new_file</code> ( string )</dt>
<dd>
<p>The file to lookup</p>
</dd>
<dt id="opt-arg2:-next_filter-Apache2::Filter">opt arg2: <code>$next_filter</code> ( <code><a>Apache2::Filter</a></code> )</dt>
<dd>
<p>See <code><a href="#C_lookup_uri_">$r->lookup_uri</a></code> for details.</p>
</dd>
<dt id="ret:-ret-Apache2::SubRequest-object">ret: <code>$ret</code> ( <code><a>Apache2::SubRequest object</a></code> )</dt>
<dd>
<p>The sub request record.</p>
</dd>
<dt id="since:-2.0.003">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>See <code><a href="#C_lookup_uri_">$r->lookup_uri</a></code> for further discussion.</p>
<h2 id="lookup_method_uri"><code>lookup_method_uri</code></h2>
<p>Create a sub request for the given URI using a specific method. This sub request can be inspected to find information about the requested URI</p>
<pre><code> $ret = $r->lookup_method_uri($method, $new_uri);
$ret = $r->lookup_method_uri($method, $new_uri, $next_filter);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object3">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-method-string">arg1: <code>$method</code> ( string )</dt>
<dd>
<p>The method to use in the new sub request (e.g. <code>"GET"</code>)</p>
</dd>
<dt id="arg2:-new_uri-string">arg2: <code>$new_uri</code> ( string )</dt>
<dd>
<p>The URI to lookup</p>
</dd>
<dt id="opt-arg3:-next_filter-Apache2::Filter-object">opt arg3: <code>$next_filter</code> ( <code><a>Apache2::Filter object</a></code> )</dt>
<dd>
<p>See <code><a href="#C_lookup_uri_">$r->lookup_uri</a></code> for details.</p>
</dd>
<dt id="ret:-ret-Apache2::SubRequest-object1">ret: <code>$ret</code> ( <code><a>Apache2::SubRequest object</a></code> )</dt>
<dd>
<p>The sub request record.</p>
</dd>
<dt id="since:-2.0.004">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>See <code><a href="#C_lookup_uri_">$r->lookup_uri</a></code> for further discussion.</p>
<h2 id="lookup_uri"><code>lookup_uri</code></h2>
<p>Create a sub request from the given URI. This sub request can be inspected to find information about the requested URI.</p>
<pre><code> $ret = $r->lookup_uri($new_uri);
$ret = $r->lookup_uri($new_uri, $next_filter);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object4">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-new_uri-string2">arg1: <code>$new_uri</code> ( string )</dt>
<dd>
<p>The URI to lookup</p>
</dd>
<dt id="opt-arg2:-next_filter-Apache2::Filter-object">opt arg2: <code>$next_filter</code> ( <code><a>Apache2::Filter object</a></code> )</dt>
<dd>
<p>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 <code><a>$r->proto_output_filters</a></code>. 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 <code><a>$r->output_filters</a></code> as an argument.</p>
</dd>
<dt id="ret:-ret-Apache2::SubRequest-object2">ret: <code>$ret</code> ( <code><a>Apache2::SubRequest object</a></code> )</dt>
<dd>
<p>The sub request record</p>
</dd>
<dt id="since:-2.0.005">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>Here is an example of a simple subrequest which serves uri <i>/new_uri</i>:</p>
<pre><code> sub handler {
my $r = shift;
my $subr = $r->lookup_uri("/new_uri");
$subr->run;
return Apache2::Const::OK;
}</code></pre>
<p>If let's say you have three request output filters registered to run for the main request:</p>
<pre><code> PerlOutputFilterHandler MyApache2::SubReqExample::filterA
PerlOutputFilterHandler MyApache2::SubReqExample::filterB
PerlOutputFilterHandler MyApache2::SubReqExample::filterC</code></pre>
<p>and you wish to run them all, the code needs to become:</p>
<pre><code> my $subr = $r->lookup_uri("/new_uri", $r->output_filters);</code></pre>
<p>and if you wish to run them all, but the first one (<code>filterA</code>), the code needs to be adjusted to be:</p>
<pre><code> my $subr = $r->lookup_uri("/new_uri", $r->output_filters->next);</code></pre>
<h2 id="run"><code>run</code></h2>
<p>Run a sub-request</p>
<pre><code> $rc = $subr->run();</code></pre>
<dl>
<dt id="obj:-subr-Apache2::RequestRec-object">obj: <code>$subr</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The sub-request (e.g. returned by <code><a href="#C_lookup_uri_">lookup_uri</a></code>)</p>
</dd>
<dt id="ret:-rc-integer">ret: <code>$rc</code> ( integer )</dt>
<dd>
<p>The return code of the handler (<code>Apache2::Const::OK</code>, <code>Apache2::Const::DECLINED</code>, etc.)</p>
</dd>
<dt id="since:-2.0.006">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h1 id="Unsupported-API">Unsupported API</h1>
<p><code>Apache2::SubRequest</code> also provides auto-generated Perl interface for a few other methods which aren't tested at the moment and therefore their API 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 <a>the mod_perl development mailing list</a> so we can help each other take the steps necessary to shift the method to an officially supported API.</p>
<h2 id="internal_fast_redirect"><code>internal_fast_redirect</code></h2>
<p>META: Autogenerated - needs to be reviewed/completed</p>
<p>Redirect the current request to a sub_req, merging the pools</p>
<pre><code> $r->internal_fast_redirect($sub_req);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object5">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-sub_req-string">arg1: <code>$sub_req</code> ( string )</dt>
<dd>
<p>A subrequest created from this request</p>
</dd>
<dt id="ret:-no-return-value3">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.007">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>META: httpd-2.0/modules/http/http_request.c declares this function as:</p>
<pre><code> /* XXX: Is this function is so bogus and fragile that we deep-6 it? */</code></pre>
<p>do we really want to expose it to mod_perl users?</p>
<h2 id="lookup_dirent"><code>lookup_dirent</code></h2>
<p>META: Autogenerated - needs to be reviewed/completed</p>
<p>Create a sub request for the given apr_dir_read result. This sub request can be inspected to find information about the requested file</p>
<pre><code> $lr = $r->lookup_dirent($finfo);
$lr = $r->lookup_dirent($finfo, $subtype);
$lr = $r->lookup_dirent($finfo, $subtype, $next_filter);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object6">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-finfo-APR::Finfo-object">arg1: <code>$finfo</code> ( <code><a>APR::Finfo object</a></code> )</dt>
<dd>
<p>The apr_dir_read result to lookup</p>
</dd>
<dt id="arg2:-subtype-integer">arg2: <code>$subtype</code> ( integer )</dt>
<dd>
<p>What type of subrequest to perform, one of;</p>
<pre><code> Apache2::SUBREQ_NO_ARGS ignore r->args and r->path_info
Apache2::SUBREQ_MERGE_ARGS merge r->args and r->path_info</code></pre>
</dd>
<dt id="arg3:-next_filter-integer">arg3: <code>$next_filter</code> ( integer )</dt>
<dd>
<p>The first filter the sub_request should use. If this is NULL, it defaults to the first filter for the main request</p>
</dd>
<dt id="ret:-lr-Apache2::RequestRec-object">ret: <code>$lr</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The new request record</p>
</dd>
<dt id="since:-2.0.008">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>META: where do we take the apr_dir_read result from?</p>
<h1 id="See-Also">See Also</h1>
<p><a>mod_perl 2.0 documentation</a>.</p>
<h1 id="Copyright">Copyright</h1>
<p>mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.</p>
<h1 id="Authors">Authors</h1>
<p><a>The mod_perl development team and numerous contributors</a>.</p>
</body>
</html>
|