⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 requestutil.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 2 页
字号:
and populate the environment variables table if disabled:  $r->subprocess_env unless $r->is_perl_option_enabled('SetupEnv');See also:L<PerlOptions|docs::2.0::user::config::config/C_PerlOptions_> andL<the equivalent function for server level PerlOptionsflags|docs::2.0::api::Apache2::ServerUtil/C_is_perl_option_enabled_>.=head2 C<location>Get the path of the E<lt>LocationE<gt> section from which the currentC<Perl*Handler> is being called.  $location = $r->location();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item ret: C<$location> ( string )=item since: 2.0.00=back=head2 C<location_merge>Merge a given C<E<lt>LocationE<lt>> container into the current requestobject:  $ret = $r->location_merge($location);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$location> ( string )The argument in a C<E<lt>LocationE<lt>> section. For example to mergea container:  <Location /foo>      ...  </Location>that argument will be I</foo>=item ret: C<$ret> ( boolean )a true value if the merge was successful (i.e. the requestC<$location> match was found), otherwise false.=item since: 2.0.00=backUseful for insertion of a configuration section into a customC<Apache2::RequestRec> object, created via theC<Apache2::RequestRec-E<gt>new()> method. See for example the L<CommandServer protocolexample|docs::2.0::user::handlers::protocols/Command_Server>.=head2 C<new>Create a new C<Apache2::RequestRec> object.  $r = Apache2::RequestRec->new($c);  $r = Apache2::RequestRec->new($c, $pool);=over 4=item obj: C<Apache2::RequestRec>( C<L<Apache2::RequestRec class name|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$c>(C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>>)=item opt arg2: C<$pool>If no C<$pool> argument is passed, C<$c-E<gt>pool> is used. That meansthat the created C<Apache2::RequestRec> object will be valid as long asthe connection object is valid.=item ret: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item since: 2.0.00=backIt's possible to reuse the HTTP framework features outside thefamiliar HTTP request cycle. It's possible to write your own full orpartial HTTP implementation without needing a running Apacheserver. You will need the C<Apache2::RequestRec> object in order to beable to reuse the rich functionality supplied via this object.See for example the L<Command Server protocolexample|docs::2.0::user::handlers::protocols/Command_Server> whichreuses HTTP AAA model under non-HTTP protocol.=head2 C<no_cache>Add/remove cache control headers:  $prev_no_cache = $r->no_cache($boolean);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$boolean> ( boolean )A true value sets the C<no_cache> request record member to a truevalue and inserts:  Pragma: no-cache  Cache-control: no-cacheinto the response headers, indicating that the data being returned isvolatile and the client should not cache it.A false value unsets the C<no_cache> request record member and thementioned headers if they were previously set.=item ret: C<$prev_no_cache> ( boolean )Should you care, the C<no_cache> request record member value prior tothe change is returned.=item since: 2.0.00=backThis method should be invoked before any response data has been sentout.=head2 C<pnotes>Share Perl variables between Perl HTTP handlers  $old_val  = $r->pnotes($key => $val);  $val      = $r->pnotes($key);  $hash_ref = $r->pnotes();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item opt arg1: C<$key> ( string )A key value=item opt arg2: C<$val> ( SCALAR )Any scalar value (e.g. a reference to an array)=item ret: (3 different possible values)if both, C<$key> and C<$val> are passed the previous value for C<$key>is returned if such existed, otherwise C<undef> is returned.if only C<$key> is passed, the current value for the given key isreturned.if no arguments are passed, a hash reference is returned, which canthen be directly accessed without going through the C<pnotes()>interface.=item since: 2.0.00=backThis method provides functionality similar to(C<L<Apache2::RequestRec::notes|docs::2.0::api::Apache2::RequestRec/C_notes_>>),but values can be any Perl variables. That also means that it can beused only between Perl modules.The values get reset automatically at the end of each HTTP request.Examples:Set a key/value pair:  $r->pnotes(foo => [1..5]);Get the value:  $val = $r->pnotes("foo");C<$val> now contains an array ref containing 5 elements (C<1..5>).Now change the existing value:  $old_val = $r->pnotes(foo => ['a'..'c']);  $val = $r->pnotes("foo");C<$old_val> now contains an array ref with 5 elements (C<1..5>) andC<$val> contains an array ref with 3 elements C<'a'>, C<'b'>, C<'c'>.Alternatively you can access the hash reference with all pnotesvalues:  $pnotes = $r->pnotes;Now we can read what's in there for the key I<foo>:  $val = $pnotes->{foo};and as before C<$val> still gives us an array ref with 3 elementsC<'a'>, C<'b'>, C<'c'>.Now we can add elements to it:  push @{ $pnotes{foo} }, 'd'..'f';and we can try to retrieve them using the hash and non-hash API:  $val1 = $pnotes{foo};  $val2 = $r->pnotes("foo");Both C<$val1> and C<$val2> contain an array ref with 6 elements(letters 'a' to 'f').Finally to reset an entry you could just assign C<undef> as a value:  $r->pnotes(foo => undef);but the entry for the key I<foo> still remains with the valueC<undef>. If you really want to completely remove it, use the hashinterface:  delete $r->pnotes->{foo};=head2 C<psignature>Get HTML describing the address and (optionally) admin of the server.  $sig = $r->psignature($prefix);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$prefix> ( string )Text which is prepended to the return value=item ret: C<$sig> ( string )HTML text describing the server. Note that depending on the value ofthe C<ServerSignature> directive, the function may return the address,including the admin information or nothing at all.=item since: 2.0.00=back=head2 C<request>Get/set the ( C<L<Apache2::RequestRecobject|docs::2.0::api::Apache2::RequestRec>> ) object for the currentrequest.  $r = Apache2::RequestUtil->request;       Apache2::RequestUtil->request($new_r);=over 4=item obj: C<Apache2> (class name)The Apache class name=item opt arg1: C<$new_r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item ret: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item since: 2.0.00=backThe get-able part of this method is only available if C<L<PerlOptions+GlobalRequest|docs::2.0::user::config::config/C_GlobalRequest_>> isin effect or if C<Apache2-E<gt>request($new_r)> was called earlier. Soinstead of setting C<L<PerlOptions+GlobalRequest|docs::2.0::user::config::config/C_GlobalRequest_>>, onecan set the global request from within the handler.=head2 C<push_handlers>Add one or more handlers to a list of handlers to be called for agiven phase.  $ok = $r->push_handlers($hook_name => \&handler);  $ok = $r->push_handlers($hook_name => ['Foo::Bar::handler', \&handler2]);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$hook_name> ( string )the phase to add the handlers to=item arg2: C<$handlers> ( CODE ref or SUB name or an ARRAY ref )a single handler CODE reference or just a name of the subroutine(fully qualified unless defined in the current package).if more than one passed, use a reference to an array of CODE refsand/or subroutine names.=item ret: C<$ok> ( boolean )returns a true value on success, otherwise a false value=item since: 2.0.00See also:C<L<$s-E<gt>add_config|docs::2.0::api::Apache2::ServerUtil/C_push_handlers_>>Note that to push input/output filters you have to useC<L<Apache2::Filter|docs::2.0::api::Apache2::Filter>> methods:C<L<add_input_filter|docs::2.0::api::Apache2::Filter/C_add_input_filter_>>andC<L<add_output_filter|docs::2.0::api::Apache2::Filter/C_add_output_filter_>>.=backExamples:A single handler:  $r->push_handlers(PerlResponseHandler => \&handler);Multiple handlers:  $r->push_handlers(PerlFixupHandler => ['Foo::Bar::handler', \&handler2]);Anonymous functions:  $r->push_handlers(PerlLogHandler => sub { return Apache2::Const::OK });=head2 C<set_basic_credentials>Populate the incoming request headers table (C<headers_in>) withauthentication headers for Basic Authorization as if the client hassubmitted those in first place:  $r->set_basic_credentials($username, $password);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$username> ( string )=item arg2: C<$password> ( string )=item ret: no return value=item since: 2.0.00=backSee for example the L<Command Server protocolexample|docs::2.0::user::handlers::protocols/Command_Server> whichreuses HTTP AAA model under non-HTTP protocol.=head2 C<set_handlers>Set a list of handlers to be called for a given phase. Any previouslyset handlers are forgotten.  $ok = $r->set_handlers($hook_name => \&handler);  $ok = $r->set_handlers($hook_name => ['Foo::Bar::handler', \&handler2]);  $ok = $r->set_handlers($hook_name => []);  $ok = $r->set_handlers($hook_name => undef);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$hook_name> ( string )the phase to set the handlers in=item arg2: C<$handlers> (CODE ref or SUB name or an ARRAY ref)a reference to a single handler CODE reference or just a name of thesubroutine (fully qualified unless defined in the current package).if more than one passed, use a reference to an array of CODE refsand/or subroutine names.if the argument is C<undef> or C<[]> the list of handlers is reset tozero.=item ret: C<$ok> ( boolean )returns a true value on success, otherwise a false value=item since: 2.0.00=backSee also:C<L<$s-E<gt>add_config|docs::2.0::api::Apache2::ServerUtil/C_set_handlers_>>Examples:A single handler:  $r->set_handlers(PerlResponseHandler => \&handler);Multiple handlers:  $r->set_handlers(PerlFixupHandler => ['Foo::Bar::handler', \&handler2]);Anonymous functions:  $r->set_handlers(PerlLogHandler => sub { return Apache2::Const::OK });Reset any previously set handlers:  $r->set_handlers(PerlCleanupHandler => []);or  $r->set_handlers(PerlCleanupHandler => undef);=head2 C<slurp_filename>Slurp the contents of C<$r-E<gt>filename>:  $content_ref = $r->slurp_filename($tainted);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )=item arg1: C<$tainted> (number)If the server is run under the tainting mode (C<-T>) which we hope youdo, by default the returned data is tainted. If an optionalC<$tainted> flag is set to zero, the data will be marked asnon-tainted.Do B<not> set this flag to zero unless you know what you are doing,you may create a security hole in your program if you do. For moreinformation see the I<perlsec> manpage.If you wonder why this option is available, it is used internally bythe C<L<ModPerl::Registry|docs::2.0::api::ModPerl::Registry>> handlerand friends, because the CGI scripts that it reads are considered safe(you could just as well C<require()> them).=item ret: C<$content_ref> ( SCALAR ref )A reference to a string with the contents=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>Possible error codes could be:C<L<APR::Const::EACCES|docs::2.0::api::APR::Const/C_APR__Const__EACCES_>>(permission problems),C<L<APR::Const::ENOENT|docs::2.0::api::APR::Const/C_APR__Const__ENOENT_>>(file not found), and others. For checking such error codes, see thedocumentation for, for example,C<L<APR::Status::is_EACCES|docs::2.0::api::APR::Status/C_is_EACCES_>>andC<L<APR::Status::is_ENOENT|docs::2.0::api::APR::Status/C_is_ENOENT_>>.=item since: 2.0.00=backNote that if you assign to C<$r-E<gt>filename> you need to L<updateits stat record|docs::2.0::api::Apache2::RequestRec/C_filename_>.=head1 See AlsoL<mod_perl 2.0 documentation|docs::2.0::index>.=head1 Copyrightmod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0.=head1 AuthorsL<The mod_perl development team and numerouscontributors|about::contributors::people>.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -