/usr/share/doc/libapache2-request-perl/html/group__apreq__xs__request.html is in libapreq2-doc 2.13-4ubuntu2.
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 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | <html>
<head>
<link rel="stylesheet" type="text/css" href="dox.css" />
<title>libapreq2-2.13: libapreq2: Apache2::Request</title>
</head>
<body>
<div id="page-header">
<p class="menu">
<a href="http://www.apache.org/">Apache Software Foundation</a> > <a href="http://httpd.apache.org">HTTP Server Project</a> >
<a href="http://httpd.apache.org/apreq/">Request Library Subproject</a></p>
<p class="apache">Apache HTTP Server Request Library</p>
<img alt="" src="feather.gif" /></div>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Apache2::Request<br>
<small>
[<a class="el" href="group__apreq__xs.html">Perl</a>]</small>
</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#apache2__request">Apache2::Request</a></li>
<ul>
<li><a href="#new">new</a></li>
<li><a href="#instance">instance</a></li>
<li><a href="#param">param</a></li>
<li><a href="#parms__params">parms, params</a></li>
<li><a href="#body">body</a></li>
<li><a href="#upload">upload</a></li>
<li><a href="#args_status">args_status</a></li>
<li><a href="#body_status">body_status</a></li>
<li><a href="#param_status">param_status</a></li>
<li><a href="#parse">parse</a></li>
</ul>
<li><a href="#subclassing_apache2__request">SUBCLASSING Apache2::Request</a></li>
<li><a href="#porting_from_1_x">PORTING from 1.X</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Apache2::Request - Methods for dealing with client request data</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
use Apache2::Request;
$req = Apache2::Request->new($r);
@foo = $req->param("foo");
$bar = $req->args("bar");</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The Apache2::Request module provides methods for parsing GET and POST parameters
encoded with either <em>application/x-www-form-urlencoded</em> or <em>multipart/form-data</em>.
Although Apache2::Request provides a few new APIs for accessing the parsed data,
it remains largely backwards-compatible with the original 1.X API. See the
<a href="#porting_from_1_x">PORTING from 1.X</a> section below for a list of known issues.</p>
<p>This manpage documents the Apache2::Request package.</p>
<p>
</p>
<hr />
<h1><a name="apache2__request">Apache2::Request</a></h1>
<p>The interface is designed to mimic the CGI.pm routines for parsing
query parameters. The main differences are</p>
<ul>
<li>
<strong>
<a name="as" class="item"><code>Apache2::Request::new</code> takes an environment-specific
object <code>$r</code> as (second) argument. Newer versions of CGI.pm also accept
this syntax within modperl.</a>
</strong>
<li>
<strong>
<a name="the_query_parameters_are_stored_in_apr_table_derived_objects_and_are_therefore_retrieved_from_the_table_by_using_case_insensitive_keys" class="item">The query parameters are stored in APR::Table derived objects, and
are therefore retrieved from the table by using case-insensitive keys.</a>
</strong>
<li>
<strong>
<a name="the_query_string_is_always_parsed_immediately_even_for_post_requests" class="item">The query string is always parsed immediately, even for POST requests.</a>
</strong>
</ul>
<p>
</p>
<h2><a name="new">new</a></h2>
<pre>
Apache2::Request->new($r, %args)</pre>
<p>Creates a new Apache2::Request object.</p>
<pre>
my $req = Apache2::Request->new($r, POST_MAX => "1M");</pre>
<p>With mod_perl2, the environment object $r must be an Apache2::RequestRec
object. In that case, all methods from Apache2::RequestRec are inherited.
In the (default) CGI environment, $r must be an APR::Pool object.</p>
<p>The following args are optional:</p>
<ul>
<li>
<strong>
<a name="post_max_max_body" class="item"><code>POST_MAX</code>, <code>MAX_BODY</code></a>
</strong>
<p>Limit the size of POST data (in bytes).</p>
</li>
<li>
<strong>
<a name="disable_uploads" class="item"><code>DISABLE_UPLOADS</code></a>
</strong>
<p>Disable file uploads.</p>
</li>
<li>
<strong>
<a name="temp_dir" class="item"><code>TEMP_DIR</code></a>
</strong>
<p>Sets the directory where upload files are spooled. On a *nix-like
that supports <em>link(2)</em>, the TEMP_DIR should be located on the same
file system as the final destination file:</p>
<pre>
use Apache2::Upload;
my $req = Apache2::Request->new($r, TEMP_DIR => "/home/httpd/tmp");
my $upload = $req->upload('file');
$upload->link("/home/user/myfile");</pre>
<p>For more details on <code>link</code>, see <a href="group__apreq__xs__upload.html">the Apache2::Upload manpage</a>.</p>
</li>
<li>
<strong>
<a name="hook_data" class="item"><code>HOOK_DATA</code></a>
</strong>
<p>Extra configuration info passed as the fourth argument
to an upload hook. See the description for the next item,
<a href="#upload_hook"><code>UPLOAD_HOOK</code></a>.</p>
</li>
<li>
<strong>
<a name="upload_hook" class="item"><code>UPLOAD_HOOK</code></a>
</strong>
<p>Sets up a callback to run whenever file upload data is read. This
can be used to provide an upload progress meter during file uploads.
Apache will automatically continue writing the original data to
$upload->fh after the hook exits.</p>
<pre>
my $transparent_hook = sub {
my ($upload, $data, $data_len, $hook_data) = @_;
warn "$hook_data: got $data_len bytes for " . $upload->name;
};</pre>
<pre>
my $req = Apache2::Request->new($r,
HOOK_DATA => "Note",
UPLOAD_HOOK => $transparent_hook,
);</pre>
</li>
</ul>
<p>
</p>
<h2><a name="instance">instance</a></h2>
<pre>
Apache2::Request->instance($r)</pre>
<p>The default (and only) behavior of <em>Apache2::Request</em> is to intelligently
cache <strong>POST</strong> data for the duration of the request. Thus there is no longer
the need for a separate <a href="#instance"><code>instance()</code></a> method as existed in <em>Apache2::Request</em>
for Apache 1.3 - all <strong>POST</strong> data is always available from each and every
<em>Apache2::Request</em> object created during the request's lifetime.</p>
<p>However an <a href="#instance"><code>instance()</code></a> method is aliased to <code>new()</code> in this release
to ease the pain of porting from 1.X to 2.X.</p>
<p>
</p>
<h2><a name="param">param</a></h2>
<pre>
$req->param()
$req->param($name)</pre>
<p>Get the request parameters (using case-insensitive keys) by
mimicing the OO interface of <code>CGI::param</code>.</p>
<pre>
# similar to CGI.pm</pre>
<pre>
my $foo_value = $req->param('foo');
my @foo_values = $req->param('foo');
my @param_names = $req->param;</pre>
<pre>
# the following differ slightly from CGI.pm</pre>
<pre>
# returns ref to APR::Request::Param::Table object representing
# all (args + body) params
my $table = $req->param;
@table_keys = keys %$table;</pre>
<p>In list context, or when invoked with no arguments as
<code>$req->param()</code>, <code>param</code> induces libapreq2 to read
and parse all remaining data in the request body.
However, <code>scalar $req->param("foo")</code> is lazy: libapreq2
will only read and parse more data if</p>
<pre>
1) no "foo" param appears in the query string arguments, AND
2) no "foo" param appears in the previously parsed POST data.</pre>
<p>In this circumstance libapreq2 will read and parse additional
blocks of the incoming request body until either</p>
<pre>
1) it has found the the "foo" param, or
2) parsing is completed.</pre>
<p>Observe that <code>scalar $req->param("foo")</code> will not raise
an exception if it can locate "foo" in the existing body or
args tables, even if the query-string parser or the body parser
has failed. In all other circumstances <code>param</code> will throw an
Apache2::Request::Error object into $@ should either parser fail.</p>
<pre>
$req->args_status(1); # set error state for query-string parser
ok $req->param_status == 1;</pre>
<pre>
$foo = $req->param("foo");
ok $foo == 1;
eval { @foo = $req->param("foo") };
ok $@->isa("Apache2::Request::Error");
undef $@;
eval { my $not_found = $req->param("non-existent-param") };
ok $@->isa("Apache2::Request::Error");</pre>
<pre>
$req->args_status(0); # reset query-string parser state to "success"</pre>
<p>Note: modifications to the <code>scalar $req->param()</code> table only
affect the returned table object (the underlying C apr_table_t is
<em>generated</em> from the parse data by apreq_params()). Modifications
do not affect the actual request data, and will not be seen by other
libapreq2 applications.</p>
<p>
</p>
<h2><a name="parms__params">parms, params</a></h2>
<p>The functionality of these functions is assumed by <code>param</code>,
so they are no longer necessary. Aliases to <code>param</code> are
provided in this release for backwards compatibility,
however they are deprecated and may be removed from a future
release.</p>
<p>
</p>
<h2><a name="body">body</a></h2>
<pre>
$req->body()
$req->body($name)</pre>
<p>Returns an <em>APR::Request::Param::Table</em> object containing the POST data
parameters of the <em>Apache2::Request</em> object.</p>
<pre>
my $body = $req->body;</pre>
<p>An optional name parameter can be passed to return the POST data
parameter associated with the given name:</p>
<pre>
my $foo_body = $req->body("foo");</pre>
<p>More generally, <code>body()</code> follows the same pattern as <code>param()</code>
with respect to its return values and argument list. The main difference
is that modifications to the <code>scalar $req->body()</code> table affect
the underlying apr_table_t attribute in apreq_request_t, so their impact
will be noticed by all libapreq2 applications during this request.</p>
<p>
</p>
<h2><a name="upload">upload</a></h2>
<pre>
$req->upload()
$req->upload($name)</pre>
<p>Requires <code>Apache2::Upload</code>. With no arguments, this method
returns an <em>APR::Request::Param::Table</em> object in scalar context,
or the names of all <em>Apache2::Upload</em> objects in list context.</p>
<p>An optional name parameter can be passed to return the <em>Apache2::Upload</em>
object associated with the given name:</p>
<pre>
my $upload = $req->upload($name);</pre>
<p>More generally, <code>upload()</code> follows the same pattern as <code>param()</code>
with respect to its return values and argument list. The main difference
is that its returned values are Apache2::Upload object refs, not
simple scalars.</p>
<p>Note: modifications to the <code>scalar $req->upload()</code> table only
affect the returned table object (the underlying C apr_table_t is
<em>generated</em> by apreq_uploads()). They do not affect the actual request
data, and will not be seen by other libapreq2 applications.</p>
<p>
</p>
<h2><a name="args_status">args_status</a></h2>
<pre>
$req->args_status()</pre>
<p>Get the <em>APR</em> status code of the query-string parser.
APR_SUCCESS on success, error otherwise.</p>
<p>
</p>
<h2><a name="body_status">body_status</a></h2>
<pre>
$req->body_status()</pre>
<p>Get the current <em>APR</em> status code of the parsed POST data.
APR_SUCCESS when parser has completed, APR_INCOMPLETE if parser
has more data to parse, APR_EINIT if no post data has been parsed,
error otherwise.</p>
<p>
</p>
<h2><a name="param_status">param_status</a></h2>
<pre>
$req->param_status()</pre>
<p>In scalar context, this returns <code>args_status</code> if there was
an error during the query-string parse, otherwise this returns
<code>body_status</code>, ie</p>
<pre>
$req->args_status || $req->body_status</pre>
<p>In list context <code>param_status</code> returns the list
<code>(args_status, body_status)</code>.</p>
<p>
</p>
<h2><a name="parse">parse</a></h2>
<pre>
$req->parse()</pre>
<p>Forces the request to be parsed immediately. In void context,
this will throw an APR::Request::Error should the either the
query-string or body parser fail. In all other contexts it will
return the two parsers' combined <em>APR</em> status code</p>
<pre>
$req->body_status || $req->args_status</pre>
<p>However <code>parse</code> should be avoided in most normal situations. For example,
in a mod_perl content handler it is more efficient to write</p>
<pre>
sub handler {
my $r = shift;
my $req = Apache2::Request->new($r);
$r->discard_request_body; # efficiently parses the request body
my $parser_status = $req->body_status;</pre>
<pre>
#...
}</pre>
<p>Calling <code>$r->discard_request_body</code> outside the content handler
is generally a mistake, so use <code>$req->parse</code> there, but
<strong>only as a last resort</strong>. The Apache2::Request API is <strong>designed</strong>
around a lazy-parsing scheme, so calling <code>parse</code> should not
affect the behavior of any other methods.</p>
<p>
</p>
<hr />
<h1><a name="subclassing_apache2__request">SUBCLASSING Apache2::Request</a></h1>
<p>If the instances of your subclass are hash references then you can actually
inherit from Apache2::Request as long as the Apache2::Request object is stored in
an attribute called "r" or "_r". (The Apache2::Request class effectively does the
delegation for you automagically, as long as it knows where to find the
Apache2::Request object to delegate to.) For example:</p>
<pre>
package MySubClass;
use Apache2::Request;
our @ISA = qw(Apache2::Request);
sub new {
my($class, @args) = @_;
return bless { r => Apache2::Request->new(@args) }, $class;
}</pre>
<p>
</p>
<hr />
<h1><a name="porting_from_1_x">PORTING from 1.X</a></h1>
<p>This is the complete list of changes to existing methods
from Apache2::Request 1.X. These issues need to be
addressed when porting 1.X apps to the new 2.X API.</p>
<ul>
<li>
<strong>
<a name="apache2_upload_is_now_a_separate_module_applications_requiring_the_upload_api_must_use_apache2_upload_in_2_x_this_is_easily_addressed_by_preloading_the_modules_during_server_startup" class="item">Apache2::Upload is now a separate module. Applications
requiring the upload API must <code>use Apache2::Upload</code> in 2.X.
This is easily addressed by preloading the modules during
server startup.</a>
</strong>
<li>
<strong>
<a name="add" class="item">You can no longer add (or set or delete) parameters in the
<code>scalar $req->param</code>, <code>scalar $req->args</code> or
<code>scalar $req->body</code> tables. Nor can you add (or set or delete)
cookies in the <code>scalar $req->jar</code> table.</a>
</strong>
<li>
<strong>
<a name="instance" class="item"><code>instance()</code> is now identical to <code>new()</code>, and is now deprecated. It
may be removed from a future 2.X release.</a>
</strong>
<li>
<strong>
<a name="parms" class="item"><code>param</code> includes the functionality of <code>parms()</code> and <code>params()</code>, so
they are now deprecated and may be removed from a future 2.X release.</a>
</strong>
<li>
<strong>
<a name="param_called_in_a_list_context_no_longer_returns_a_unique_list_of_paramaters_the_returned_list_contains_multiple_instances_of_the_parameter_name_for_multivalued_fields" class="item"><code>param</code> called in a list context no longer returns a unique list of
paramaters. The returned list contains multiple instances of the
parameter name for multivalued fields.</a>
</strong>
</ul>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="group__apreq__xs__apr__request__param.html">the APR::Request::Param manpage</a>, <a href="group__apreq__xs__apr__request__error.html">the APR::Request::Error manpage</a>, <a href="group__apreq__xs__upload.html">the Apache2::Upload manpage</a>,
<a href="group__apreq__xs__cookie.html">the Apache2::Cookie manpage</a>, APR::Table(3).</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<pre>
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at</pre>
<pre>
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></pre>
<pre>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>
</div>
<div id="footer">
<p class="apache">
Copyright © 2003-2006 <a href="http://www.apache.org">The Apache Software Foundation</a>.<br/>
See <a href="apreq_license.html">LICENSE</a>.</p>
<p class="menu">
<span style="color:#aaa">page generated by <a href="http://www.doxygen.org/"><code>doxygen</code></a>
version 1.5.6 on 25 Nov 2010</span>
</p>
</div>
</body>
</html>
|