📄 hookrun.pm
字号:
# # /*# * *********** WARNING **************# * This file generated by ModPerl::WrapXS/0.01# * Any changes made here will be lost# * ***********************************# * 01: lib/ModPerl/Code.pm:708# * 02: lib/ModPerl/WrapXS.pm:624# * 03: lib/ModPerl/WrapXS.pm:1173# * 04: Makefile.PL:423# * 05: Makefile.PL:325# * 06: Makefile.PL:56# */# package Apache2::HookRun;use strict;use warnings FATAL => 'all';use Apache2::XSLoader ();our $VERSION = '2.000002';Apache2::XSLoader::load __PACKAGE__;1;__END__=head1 NAMEApache2::HookRun - Perl API for Invoking Apache HTTP phases=head1 Synopsis # httpd.conf PerlProcessConnectionHandler MyApache2::PseudoHTTP::handler #file:MyApache2/PseudoHTTP.pm #--------------------------- package MyApache2::PseudoHTTP; use Apache2::HookRun (); use Apache2::RequestUtil (); use Apache2::RequestRec (); use Apache2::Const -compile => qw(OK DECLINED DONE SERVER_ERROR); # implement the HTTP protocol cycle in protocol handler sub handler { my $c = shift; my $r = Apache2::RequestRec->new($c); # register any custom callbacks here, e.g.: # $r->push_handlers(PerlAccessHandler => \&my_access); $rc = $r->run_post_read_request(); return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_translate_name; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_map_to_storage; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; # this must be run all a big havoc will happen in the following # phases $r->location_merge($path); $rc = $r->run_header_parser; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; my $args = $r->args || ''; if ($args eq 'die') { $r->die(Apache2::Const::SERVER_ERROR); return Apache2::Const::DONE; } $rc = $r->run_access_checker; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_auth_checker; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_check_user_id; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_type_checker; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_fixups; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; # $r->run_handler is called internally by $r->invoke_handler, # invoke_handler sets all kind of filters, and does a few other # things but it's possible to call $r->run_handler, bypassing # invoke_handler $rc = $r->invoke_handler; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; $rc = $r->run_log_transaction; return $rc unless $rc == Apache2::Const::OK or $rc == Apache2::Const::DECLINED; return Apache2::Const::OK; }=head1 DescriptionC<Apache2::HookRun> exposes parts of the Apache HTTP protocolimplementation, responsible for invoking callbacks for each L<HTTPRequest cyclephase|docs::2.0::user::handlers::http/HTTP_Request_Cycle_Phases>.Armed with that API, you could run some of the http protocol frameworkparts when implementing your own protocols. For example see how HTTPAAA (access, auth and authz) hooks are called from a protocol handler,implementing L<a commandserver|docs::2.0::user::handlers::protocols/Command_Server>, which hasnothing to do with HTTP. Also you can see in L<Synopsis|/Synopsis> howto re-implement Apache HTTP cycle in the protocol handler.Using this API you could probably also change the normal Apachebehavior (e.g. invoking some hooks earlier than normal, or later), butbefore doing that you will probably need to spend some time readingthrough the Apache C code. That's why some of the methods in thisdocument, point you to the specific functions in the Apache sourcecode. If you just try to use the methods from this module, withoutunderstanding them well, don't be surprised if you will get some nastycrashes, from which mod_perl can't protect you.=head1 APIC<Apache2::HookRun> provides the following functions and/or methods:=head2 C<die>Kill the current request $r->die($type);=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item arg1: C<$type> ( integer )Why the request is dieing. Expects an Apache status constant.=item ret: no return value=item since: 2.0.00=backThis method doesn't really abort the request, it just handles thesending of the error response, logging the error and such. You wantto take a look at the internals of C<ap_die()> inF<httpd-2.0/modules/http/http_request.c> for more details.=head2 C<invoke_handler>Run theL<response|docs::2.0::user::handlers::http/PerlResponseHandler> phase. $rc = $r->invoke_handler();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::HTTP_...>=item since: 2.0.00=backC<invoke_handler()> allows modules to insert filters, sets a defaulthandler if none is set, runs C<L<run_handler()|/C_run_handler_>> andhandles some errors.For more details see C<ap_invoke_handler()> inF<httpd-2.0/server/config.c>.=head2 C<run_access_checker>Run the resource L<accesscontrol|docs::2.0::user::handlers::http/PerlAccessHandler> phase. $rc = $r->run_access_checker();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )the current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis phase runs before a user is authenticated, so this hook is reallyto apply additional restrictions independent of a user. It also runsindependent of 'C<Require>' directive usage.=head2 C<run_auth_checker>Run theL<authentication|docs::2.0::user::handlers::http/PerlAuthenHandler>phase. $rc = $r->run_auth_checker();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )the current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis phase is used to check to see if the resource being requested isavailable for the authenticated user (C<$r-E<gt>user> andC<$r-E<gt>ap_auth_type>).It runs after the L<access_checker|/C_run_access_checker_> andL<check_user_id|/C_run_auth_checker_> hooks.Note that it will only be called if Apache determines that accesscontrol has been applied to this resource (through a 'C<Require>'directive).=head2 C<run_check_user_id>Run theL<authorization|docs::2.0::user::handlers::http/PerlAuthzHandler>phase. $rc = $r->run_check_user_id();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis hook is used to analyze the request headers, authenticate theuser, and set the user information in the request record(C<$r-E<gt>user> and C<$r-E<gt>ap_auth_type>).This hook is only run when Apache determines thatauthentication/authorization is required for this resource (asdetermined by the 'C<Require>' directive).It runs after the L<access_checker|/C_run_access_checker_> hook, andbefore the L<auth_checker|/C_run_auth_checker_> hook.=head2 C<run_fixups>Run the L<fixup|docs::2.0::user::handlers::http/PerlFixupHandler>phase. $rc = $r->run_fixups();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis phase allows modules to perform module-specific fixing of HTTPheader fields. This is invoked just before theL<response|docs::2.0::user::handlers::http/PerlResponseHandler> phase.=head2 C<run_handler>Run theL<response|docs::2.0::user::handlers::http/PerlResponseHandler> phase. $rc = $r->run_handler();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The request_rec=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backC<run_handler()> is called internally byC<L<invoke_handler()|/C_invoke_handler_>>. Use C<run_handler()> onlyif you want to bypass the extra functionality provided byC<L<invoke_handler()|/C_invoke_handler_>>.=head2 C<run_header_parser>Run the L<headerparser|docs::2.0::user::handlers::http/PerlHeaderParserHandler> phase. $rc = $r->run_header_parser();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )C<Apache2::Const::OK> or C<Apache2::Const::DECLINED>.=item since: 2.0.00=back=head2 C<run_log_transaction>Run the L<logging|docs::2.0::user::handlers::http/PerlLogHandler>phase. $rc = $r->run_log_transaction();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>=item since: 2.0.00=backThis hook allows modules to perform any module-specific loggingactivities over and above the normal server things.=head2 C<run_map_to_storage>Run theL<map_to_storage|docs::2.0::user::handlers::http/PerlMapToStorageHandler>phase. $rc = $r->run_map_to_storage();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )C<Apache2::Const::DONE> (or C<Apache2::HTTP_*>) if this contextless request wasjust fulfilled (such as C<TRACE>), C<Apache2::Const::OK> if this is not afile, and C<Apache2::Const::DECLINED> if this is a file. The coremap_to_storage (C<Apache2::HOOK_RUN_LAST>) will C<directory_walk()> andC<file_walk()> the C<$r-E<gt>filename> (all internal C functions).=item since: 2.0.00=backThis phase allows modules to set the per_dir_config based on their owncontext (such as C<E<lt>ProxyE<gt>> sections) and responds tocontextless requests such as C<TRACE> that need no security orfilesystem mapping based on the filesystem.=head2 C<run_post_read_request>Run theL<post_read_request|docs::2.0::user::handlers::http/PerlPostReadRequestHandler>phase. $rc = $r->run_post_read_request();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK> orC<Apache2::Const::DECLINED>.=item since: 2.0.00=backThis phase is run right after C<read_request()> orC<internal_redirect()>, and not run during any subrequests. This hookallows modules to affect the request immediately after the request hasbeen read, and before any other phases have been processes. Thisallows modules to make decisions based upon the input header fields=head2 C<run_translate_name>Run the L<translate|docs::2.0::user::handlers::http/PerlTransHandler>phase. $rc = $r->run_translate_name();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )The current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis phase gives modules an opportunity to translate the URI into anactual filename. If no modules do anything special, the server'sdefault rules will be applied.=head2 C<run_type_checker>Run theL<type_checker|docs::2.0::user::handlers::http/PerlTypeHandler> phase. $rc = $r->run_type_checker();=over 4=item obj: C<$r>( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> )the current request=item ret: C<$rc> ( integer )The status of the current phase run: C<Apache2::Const::OK>,C<Apache2::Const::DECLINED>, C<Apache2::HTTP_...>.=item since: 2.0.00=backThis phase is used to determine and/or set the various document typeinformation bits, like C<Content-type> (via C<$r-E<gt>content_type>),language, etc.=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 + -