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
|
<html>
<head>
<link rel="stylesheet" type="text/css" href="dox.css" />
<title>libapreq2-2.17: APR::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.9.1 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">APR::Request<div class="ingroups"><a class="el" href="group__apreq__lang.html">Language Bindings</a> » <a class="el" href="group__apreq__xs.html">Perl</a></div></div> </div>
</div><!--header-->
<div class="contents">
<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="#METHODS">METHODS</a>
<ul>
<li><a href="#handle">handle</a></li>
</ul>
</li>
<li><a href="#METHODS1">METHODS</a>
<ul>
<li><a href="#pool">pool</a></li>
<li><a href="#bucket_alloc">bucket_alloc</a></li>
<li><a href="#jar_status">jar_status</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>
<li><a href="#jar">jar</a></li>
<li><a href="#args">args</a></li>
<li><a href="#body">body</a></li>
<li><a href="#param">param</a></li>
<li><a href="#upload">upload</a></li>
<li><a href="#read_limit">read_limit</a></li>
<li><a href="#brigade_limit">brigade_limit</a></li>
<li><a href="#temp_dir">temp_dir</a></li>
<li><a href="#disable_uploads">disable_uploads</a></li>
<li><a href="#upload_hook">upload_hook</a></li>
<li><a href="#import">import</a></li>
</ul>
</li>
<li><a href="#SUBROUTINES">SUBROUTINES</a>
<ul>
<li><a href="#encode">encode</a></li>
<li><a href="#decode">decode</a></li>
</ul>
</li>
<li><a href="#SUBCLASSING">SUBCLASSING</a></li>
<li><a href="#METHODS2">METHODS</a>
<ul>
<li><a href="#cookie_class">cookie_class</a></li>
<li><a href="#get">get</a></li>
<li><a href="#FETCH">FETCH</a></li>
<li><a href="#EXISTS">EXISTS</a></li>
<li><a href="#FIRSTKEY">FIRSTKEY</a></li>
<li><a href="#NEXTKEY">NEXTKEY</a></li>
<li><a href="#do">do</a></li>
</ul>
</li>
<li><a href="#METHODS3">METHODS</a>
<ul>
<li><a href="#param_class">param_class</a></li>
<li><a href="#get1">get</a></li>
<li><a href="#FETCH1">FETCH</a></li>
<li><a href="#EXISTS1">EXISTS</a></li>
<li><a href="#NEXTKEY1">NEXTKEY</a></li>
<li><a href="#FIRSTKEY1">FIRSTKEY</a></li>
<li><a href="#do1">do</a></li>
</ul>
</li>
<li><a href="#SEE-ALSO">SEE ALSO</a></li>
<li><a href="#COPYRIGHT">COPYRIGHT</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>APR::Request - wrapper for libapreq2's module/handle API.</p>
<h1 id="SYNOPSIS">SYNOPSIS</h1>
<pre><code>use APR::Request;
$req = APR::Request::Custom->handle($pool,
"foo=arg1&bar=arg2",
"apache=quux",
$parser, 1e6, $bb);
$param = $req->param("foo");
$cookie = $req->jar("apache");</code></pre>
<h1 id="DESCRIPTION">DESCRIPTION</h1>
<p>The <code>APR::Request</code> module provides the base methods for interfacing with libapreq2's module API. It also provides a few utility functions and constants.</p>
<p>This manpage documents version 2.17 of the APR::Request, APR::Request::Custom, APR::Request::Cookie::Table, and APR::Request::Param::Table packages.</p>
<h1 id="METHODS">METHODS</h1>
<p>APR::Request::Custom - derived from APR::Request.</p>
<h2 id="handle">handle</h2>
<pre><code>APR::Request::Custom->handle($pool,
$query_string,
$cookie_header,
$parser,
$read_limit,
$brigade)</code></pre>
<p>Creates a new APR::Request::Custom object. The $query_string and $cookie_headers are immediately parsed into the <code>args</code> and <code>jar</code> tables. The $parser is an APR::Request::Parser object which is invoked when fetching <code>body</code> entries from the $brigade. The $read_limit represents the maximum number of bytes this handle may feed into the parser.</p>
<h1 id="METHODS1">METHODS</h1>
<p>APR::Request</p>
<h2 id="pool">pool</h2>
<pre><code>$req->pool()</code></pre>
<p>Returns the APR::Pool object associated to this handle.</p>
<h2 id="bucket_alloc">bucket_alloc</h2>
<pre><code>$req->bucket_alloc()</code></pre>
<p>Returns the APR::BucketAlloc object associated to this handle.</p>
<h2 id="jar_status">jar_status</h2>
<pre><code>$req->jar_status()</code></pre>
<p>Returns the final status code of the handle's cookie header parser.</p>
<h2 id="args_status">args_status</h2>
<pre><code>$req->args_status()</code></pre>
<p>Returns the final status code of the handle's query-string parser.</p>
<h2 id="body_status">body_status</h2>
<pre><code>$req->body_status()</code></pre>
<p>Returns the final status code of the handle's body parser.</p>
<h2 id="param_status">param_status</h2>
<pre><code>$req->param_status()</code></pre>
<p>Returns <code>($req->args_status, $req->body_status)</code> in list context; otherwise returns <code>$req->args_status || $req->body_status</code>.</p>
<h2 id="parse">parse</h2>
<pre><code>$req->parse()</code></pre>
<p>Parses the jar, args, and body tables. Returns <code>$req->jar_status, $req->args_status, $req->body_status</code>.</p>
<pre><code>@status = $req->parse;
ok @status == 3;
ok $status[0] == $req->jar_status;
ok $status[1] == $req->args_status;
ok $status[2] == $req->body_status;</code></pre>
<h2 id="jar">jar</h2>
<pre><code>$req->jar()
$req->jar($key)</code></pre>
<p>With no arguments, this method returns a tied APR::Request::Cookie::Table object (or undef if the "Cookie" header is absent) in scalar context, or the names (in order, with repetitions) of all the parsed cookies.</p>
<p>With the <code>$key</code> argument, in scalar context this method fetches the first matching cookie. In list context it returns all matching cookies. The returned cookies are the values as they appeared in the incoming Cookie header.</p>
<p>jar() will throw an APR::Request::Error object whenever jar_status() is non-zero and the return value is potentially invalid (eg <code>scalar $req->jar($key)</code> will not die if the desired cookie was successfully parsed).</p>
<pre><code>$jar = $req->jar;
@cookie_names = $req->jar;
ok $jar->isa("APR::Request::Cookie::Table");
ok shift @cookie_names eq $_ for keys %$jar;
$cookie = $req->jar("apache");
@cookies = $req->jar("apache");</code></pre>
<h2 id="args">args</h2>
<pre><code>$req->args()
$req->args($key)</code></pre>
<p>With no arguments, this method returns a tied APR::Request::Param::Table object (or undef if the query string is absent) in scalar context, or the names (in order, with repetitions) of all the parsed query-string arguments.</p>
<p>With the <code>$key</code> argument, in scalar context this method fetches the first matching query-string arg. In list context it returns all matching args.</p>
<p>args() will throw an APR::Request::Error object whenever args_status() is non-zero and the return value is potentially invalid (eg <code>scalar $req->args($key)</code> will not die if the desired query argument was successfully parsed).</p>
<pre><code>$args = $req->args;
@arg_names = $req->args;
ok $args->isa("APR::Request::Param::Table");
ok shift @arg_names eq $_ for keys %$args;
$foo = $req->args("foo");
@bar = $req->args("bar");</code></pre>
<h2 id="body">body</h2>
<pre><code>$req->body()
$req->body($key)</code></pre>
<p>With no arguments, this method returns a tied APR::Request::Param::Table object (or undef if the request body is absent) in scalar context, or the names (in order, with repetitions) of all the parsed cookies.</p>
<p>With the <code>$key</code> argument, in scalar context this method fetches the first matching body param. In list context it returns all matching body params.</p>
<p>body() will throw an APR::Request::Error object whenever body_status() is non-zero and the return value is potentially invalid (eg <code>scalar $req->body($key)</code> will not die if the desired body param was successfully parsed).</p>
<pre><code>$body = $req->body;
@body_names = $req->body;
ok $body->isa("APR::Request::Param::Table");
ok shift @body_names eq $_ for keys %$body;
$alpha = $req->body("alpha");
@beta = $req->body("beta");</code></pre>
<h2 id="param">param</h2>
<pre><code>$req->param()
$req->param($key)</code></pre>
<p>With no arguments, this method returns a tied APR::Request::Param::Table object (or undef, if the query string and request body are absent) in scalar context, or the names (in order, with repetitions) of all the incoming (args + body) params.</p>
<p>With the <code>$key</code> argument, in scalar context this method fetches the first matching param. In list context it returns all matching params.</p>
<p>param() will throw an APR::Request::Error object whenever param_status() is non-zero and the return value is potentially invalid (eg <code>scalar $req->param($key)</code> will not die if the desired param was successfully parsed).</p>
<pre><code>$param = $req->param;
@param_names = $req->param;
ok $param->isa("APR::Request::Param::Table");
ok shift @param_names eq $_ for keys %$param;
$foo = $req->param("foo");
@foo = $req->param("foo");</code></pre>
<h2 id="upload">upload</h2>
<pre><code>$req->upload()
$req->upload($key)</code></pre>
<p>With no arguments, this method returns a tied APR::Request::Param::Table object (or undef if the request body is absent) in scalar context (whose entries are APR::Request::Param objects), or the names (in order, with repetitions) of all the incoming uploads.</p>
<p>With the <code>$key</code> argument, in scalar context this method fetches the first matching upload. In list context it returns all matching uploads. The return values are APR::Request::Param objects.</p>
<p>upload() will throw an APR::Request::Error object whenever body_status() is non-zero.</p>
<pre><code>$uploads = $req->upload;
@upload_names = $req->upload;
ok $uploads->isa("APR::Request::Param::Table");
ok shift @upload_names eq $_ for keys %$uploads;
ok $_->upload for values %$uploads;
$up = $req->upload("beta");
@ups = $req->upload("beta");
ok $_->isa("APR::Request::Param") for $up, @ups;
ok $_->upload for $up, @ups;</code></pre>
<h2 id="read_limit">read_limit</h2>
<pre><code>$req->read_limit()
$req->read_limit($set)</code></pre>
<p>Get/set the read limit, which controls the total amount of bytes that can be fed to the current parser.</p>
<h2 id="brigade_limit">brigade_limit</h2>
<pre><code>$req->brigade_limit()
$req->brigade_limit($set)</code></pre>
<p>Get/set the brigade_limit for the current parser. This limit determines how many bytes of a file upload that the parser may spool into main memory. Uploads exceeding this limit are written directly to disk.</p>
<h2 id="temp_dir">temp_dir</h2>
<pre><code>$req->temp_dir()
$req->temp_dir($set)</code></pre>
<p>Get/set the spool directory for uploads which exceed the configured brigade_limit.</p>
<h2 id="disable_uploads">disable_uploads</h2>
<pre><code>$req->disable_uploads()</code></pre>
<p>Engage the disable_uploads hook for this request.</p>
<h2 id="upload_hook">upload_hook</h2>
<pre><code>$req->upload_hook($callback)</code></pre>
<p>Add an upload hook callback for this request. The arguments to the $callback sub are ($upload, $new_data).</p>
<h2 id="import">import</h2>
<p>Exports a list of subs into the caller's package.</p>
<h1 id="SUBROUTINES">SUBROUTINES</h1>
<p>APR::Request</p>
<h2 id="encode">encode</h2>
<pre><code>encode($string)</code></pre>
<p>Exportable sub which returns the url-encoded form of <code>$string</code>.</p>
<h2 id="decode">decode</h2>
<pre><code>decode($string)</code></pre>
<p>Exportable sub which returns the url-decoded form of <code>$string</code>.</p>
<h1 id="SUBCLASSING">SUBCLASSING</h1>
<p>APR::Request</p>
<p>If the instances of your subclass are hash references then you can actually inherit from APR::Request as long as the APR::Request object is stored in an attribute called "r" or "_r". (The APR::Request class effectively does the delegation for you automagically, as long as it knows where to find the APR::Request object to delegate to.) For example:</p>
<pre><code>package MySubClass;
use APR::Request::Custom;
our @ISA = qw(APR::Request);
sub new {
my($class, @args) = @_;
return bless { r => APR::Request::Custom->handle(@args) }, $class;
}</code></pre>
<h1 id="METHODS2">METHODS</h1>
<pre><code>APR::Request::Cookie::Table - read-only version of APR::Table.</code></pre>
<p>Tables in this class normally arise from calls to <code>APR::Request::jar()</code>.</p>
<h2 id="cookie_class">cookie_class</h2>
<pre><code>$table->cookie_class()
$table->cookie_class($set)</code></pre>
<p>Get/set the class each table element is blessed into during a <a>get</a> or <a>FETCH</a> call. If defined, the class must be derived from APR::Request::Cookie. When called with $set, it returns the $table. Otherwise it returns the name of the current class, or undef if no cookie class is defined.</p>
<h2 id="get">get</h2>
<pre><code>$table->get($key)</code></pre>
<p>Same as FETCH.</p>
<h2 id="FETCH">FETCH</h2>
<pre><code>$table->FETCH($key)</code></pre>
<p>In scalar context, this returns the first value matching $key (note: see NEXTKEY for additional notes). The match is always case-insensitive. In list context, this returns all matching values. Note: the type of the return values depends on the table's current cookie_class.</p>
<h2 id="EXISTS">EXISTS</h2>
<p>Synonym for <code>defined</code>; these tables are not allowed to contain undefined values. Since these are constant tables, they don't autovivify either.</p>
<h2 id="FIRSTKEY">FIRSTKEY</h2>
<pre><code>$table->FIRSTKEY()</code></pre>
<p>Returns the first key in the table.</p>
<h2 id="NEXTKEY">NEXTKEY</h2>
<pre><code>$table->NEXTKEY()</code></pre>
<p>Returns the next key in the table. For perl 5.8+, if the key is multivalued, a subsequent FETCH on this key will return the corresponding value, until either NEXTKEY or FIRSTKEY is invoked again. For perl 5.6, FETCH always returns the first value.</p>
<h2 id="do">do</h2>
<pre><code>$table->do($callback, @keys)</code></pre>
<p>Same as APR::Table::do; iterates over the table calling $callback->($key, $value) for each matching @keys. If @keys is empty, this iterates over the entire table.</p>
<p>Note: The type of $value inserted into the callback depends on the table's current cookie_class.</p>
<h1 id="METHODS3">METHODS</h1>
<p>APR::Request::Param::Table</p>
<h2 id="param_class">param_class</h2>
<pre><code>$table->param_class()
$table->param_class($set)</code></pre>
<p>Get/set the class each table element is blessed into during a <code>get</code> or <code>FETCH</code> call. If defined, the class must be derived from APR::Request::Param. When called with $set, it returns the $table. Otherwise it returns the name of the current class, or undef if no param class is defined.</p>
<h2 id="get1">get</h2>
<pre><code>$table->get($key)</code></pre>
<p>Same as FETCH.</p>
<h2 id="FETCH1">FETCH</h2>
<pre><code>$table->FETCH($key)</code></pre>
<p>In scalar context, this returns the first value matching $key (see NEXTKEY for additional notes on this). The match is always case-insensitive. In list context, this returns all matching values. Note: the type of the return values depends on the table's current param_class.</p>
<h2 id="EXISTS1">EXISTS</h2>
<p>Synonym for <code>defined</code>; these tables are not allowed to contain undefined values. Since these are constant tables, they don't autovivify either.</p>
<h2 id="NEXTKEY1">NEXTKEY</h2>
<pre><code>$table->NEXTKEY()</code></pre>
<p>Returns the next key in the table. For perl 5.8+, if the key is multivalued, a subsequent FETCH on this key will return the corresponding value, until either NEXTKEY or FIRSTKEY is invoked again. For perl 5.6, FETCH always returns the first value.</p>
<h2 id="FIRSTKEY1">FIRSTKEY</h2>
<pre><code>$table->FIRSTKEY()</code></pre>
<p>Returns the first key in the table.</p>
<h2 id="do1">do</h2>
<pre><code>$table->do($callback, @keys)</code></pre>
<p>Same as APR::Table::do; iterates over the table calling $callback->($key, $value) for each matching @keys. If @keys is empty, this iterates over the entire table.</p>
<p>Note: The type of $value inserted into the callback depends on the table's current value_class.</p>
<h1 id="SEE-ALSO">SEE ALSO</h1>
<p><a>APR::Request::Error</a>, <a>APR::Request::Param</a>, <a>APR::Request::Cookie</a>, <a>APR::Request::Parser</a></p>
<h1 id="COPYRIGHT">COPYRIGHT</h1>
<pre><code>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
http://www.apache.org/licenses/LICENSE-2.0
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.</code></pre>
</div><!-- contents -->
<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.9.1 on Thu Aug 18 2022</span>
</p>
</div>
</body>
</html>
|