📄 request.pod
字号:
=head2 upload $req->upload() $req->upload($key)With no arguments, this method returns a tied APR::Request::Param::Tableobject (or undef if the request body is absent) in scalar context (whoseentries are APR::Request::Param objects), or the names (in order, with repetitions) of all the incoming uploads.With the C<$key> argument, in scalar context this method fetches the firstmatching upload. In list context it returns all matching uploads. The returnvalues are APR::Request::Param objects.upload() will throw an APR::Request::Error object whenever body_status() is non-zero.=for example begin $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;=for example end=for example_testing is $up, "foo.txt", "scalar upload"; is "@ups", "foo.txt", "list upload";=head2 read_limit $req->read_limit() $req->read_limit($set)Get/set the read limit, which controls the total amount ofbytes that can be fed to the current parser.=head2 brigade_limit $req->brigade_limit() $req->brigade_limit($set)Get/set the brigade_limit for the current parser. This limitdetermines how many bytes of a file upload that the parser mayspool into main memory. Uploads exceeding this limit are writtendirectly to disk.=head2 temp_dir $req->temp_dir() $req->temp_dir($set)Get/set the spool directory for uploads which exceed the configuredbrigade_limit.=head2 disable_uploads $req->disable_uploads()Engage the disable_uploads hook for this request.=head2 upload_hook $req->upload_hook($callback)Add an upload hook callback for this request. Thearguments to the $callback sub are ($upload, $new_data).=head2 importExports a list of subs into the caller's package.=head1 SUBROUTINESAPR::Request=head2 encode encode($string)Exportable sub which returns the url-encoded form of C<$string>.=head2 decode decode($string)Exportable sub which returns the url-decoded form of C<$string>.=head1 SUBCLASSINGAPR::RequestIf the instances of your subclass are hash references then you can actuallyinherit from APR::Request as long as the APR::Request object is stored inan attribute called "r" or "_r". (The APR::Request class effectively does thedelegation for you automagically, as long as it knows where to find theAPR::Request object to delegate to.) For example: 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; }=head1 METHODS APR::Request::Cookie::Table - read-only version of APR::Table.Tables in this class normally arise from calls toC<< APR::Request::jar() >>.=head2 cookie_class $table->cookie_class() $table->cookie_class($set)Get/set the class each table element is blessed into during aL<get> or L<FETCH> call. If defined, the class must be derivedfrom APR::Request::Cookie. When called with $set, it returnsthe $table. Otherwise it returns the name of the current class,or undef if no cookie class is defined.=for example begin $jar = $req->jar; { package FOO; use base 'APR::Request::Cookie'; } $jar->cookie_class("FOO"); ok $_->isa("FOO") for values %$jar;=for example end=for example_testing $jar->do(sub { ok $_[1]->isa("FOO"); });=head2 get $table->get($key)Same as FETCH.=head2 FETCH $table->FETCH($key)In scalar context, this returns the first value matching$key (note: see NEXTKEY for additional notes). The matchis always case-insensitive. In list context, this returnsall matching values. Note: the type of the return valuesdepends on the table's current cookie_class.=head2 EXISTSSynonym for C<< defined >>; these tables are notallowed to contain undefined values. Since theseare constant tables, they don't autovivify either.=head2 FIRSTKEY $table->FIRSTKEY()Returns the first key in the table.=head2 NEXTKEY $table->NEXTKEY()Returns the next key in the table. For perl 5.8+,if the key is multivalued, a subsequent FETCH onthis key will return the corresponding value, untileither NEXTKEY or FIRSTKEY is invoked again. Forperl 5.6, FETCH always returns the first value.=head2 do $table->do($callback, @keys)Same as APR::Table::do; iterates over the tablecalling $callback->($key, $value) for each matching@keys. If @keys is empty, this iterates over theentire table.Note: The type of $value inserted into the callbackdepends on the table's current cookie_class.=head1 METHODSAPR::Request::Param::Table=head2 param_class $table->param_class() $table->param_class($set)Get/set the class each table element is blessed into during aC<get> or C<FETCH> call. If defined, the class must be derivedfrom APR::Request::Param. When called with $set, it returnsthe $table. Otherwise it returns the name of the current class,or undef if no param class is defined.=for example begin $body = $req->body; { package BAR; use base 'APR::Request::Param'; } $body->param_class("BAR"); ok $_->isa("BAR") for values %$body;=for example end=for example_testing $body->do(sub { ok $_[1]->isa("BAR"); });=head2 get $table->get($key)Same as FETCH.=head2 FETCH $table->FETCH($key)In scalar context, this returns the first value matching$key (see NEXTKEY for additional notes on this). The matchis always case-insensitive. In list context, this returnsall matching values. Note: the type of the return valuesdepends on the table's current param_class.=head2 EXISTSSynonym for C<< defined >>; these tables are notallowed to contain undefined values. Since theseare constant tables, they don't autovivify either.=head2 NEXTKEY $table->NEXTKEY()Returns the next key in the table. For perl 5.8+,if the key is multivalued, a subsequent FETCH onthis key will return the corresponding value, untileither NEXTKEY or FIRSTKEY is invoked again. Forperl 5.6, FETCH always returns the first value.=head2 FIRSTKEY $table->FIRSTKEY()Returns the first key in the table.=head2 do $table->do($callback, @keys)Same as APR::Table::do; iterates over the tablecalling $callback->($key, $value) for each matching@keys. If @keys is empty, this iterates over theentire table.Note: The type of $value inserted into the callbackdepends on the table's current value_class.=head1 SEE ALSOL<APR::Request::Error>, L<APR::Request::Param>,L<APR::Request::Cookie>, L<APR::Request::Parser>=head1 COPYRIGHT Copyright 2003-2006 The Apache Software Foundation Licensed 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -