Apache2::HookRun - Perl API For Invoking Apache HTTP Phases

2y ago
45 Views
1 Downloads
26.72 KB
11 Pages
Last View : 29d ago
Last Download : 1y ago
Upload by : Grady Mosby
Transcription

Apache2::HookRun - Perl API for Invoking Apache HTTP phases1 Apache2::HookRun - Perl API for Invoking Apache HTTP phases1 Apache2::HookRun - Perl API for Invoking ApacheHTTP phases15 Feb 20141

1.1 Synopsis1.1 Synopsis# httpd.confPerlProcessConnectionHandler doHTTP.pm#--------------------------package MyApache2::PseudoHTTP;use Apache2::HookRun ();use Apache2::RequestUtil ();use Apache2::RequestRec ();use Apache2::Const -compile qw(OK DECLINED DONE SERVER ERROR);# implementsub handlermy c my r the HTTP protocol cycle in protocol handler{shift;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;215 Feb 2014

Apache2::HookRun - Perl API for Invoking Apache HTTP phases1.2 Descriptionreturn 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;}1.2 DescriptionApache2::HookRun exposes parts of the Apache HTTP protocol implementation, responsible forinvoking callbacks for each HTTP Request cycle phase.Armed with that API, you could run some of the http protocol framework parts when implementing yourown protocols. For example see how HTTP AAA (access, auth and authz) hooks are called from a protocol handler, implementing a command server, which has nothing to do with HTTP. Also you can see inSynopsis how to re-implement Apache HTTP cycle in the protocol handler.Using this API you could probably also change the normal Apache behavior (e.g. invoking some hooksearlier than normal, or later), but before doing that you will probably need to spend some time readingthrough the Apache C code. That’s why some of the methods in this document, point you to the specificfunctions in the Apache source code. If you just try to use the methods from this module, without understanding them well, don’t be surprised if you will get some nasty crashes, from which mod perl can’tprotect you.1.3 APIApache2::HookRun provides the following functions and/or methods:1.3.1 dieKill the current request r- die( type);obj: r ( Apache2::RequestRec object )The current request15 Feb 20143

1.3.2 invoke handlerarg1: type ( integer )Why the request is dieing. Expects an Apache status constant.ret: no return valuesince: 2.0.00This method doesn’t really abort the request, it just handles the sending of the error response, logging theerror and such. You want to take a look at the internals of ap die() inhttpd-2.0/modules/http/http request.c for more details.1.3.2 invoke handlerRun the response phase. rc r- invoke handler();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::HTTP .since: 2.0.00invoke handler() allows modules to insert filters, sets a default handler if none is set, runsrun handler() and handles some errors.For more details see ap invoke handler() in httpd-2.0/server/config.c.1.3.3 run access checkerRun the resource access control phase. rc r- run access checker();obj: r ( Apache2::RequestRec object )the current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00415 Feb 2014

Apache2::HookRun - Perl API for Invoking Apache HTTP phases1.3.4 run auth checkerThis phase runs before a user is authenticated, so this hook is really to apply additional restrictions independent of a user. It also runs independent of ’Require’ directive usage.1.3.4 run auth checkerRun the authentication phase. rc r- run auth checker();obj: r ( Apache2::RequestRec object )the current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00This phase is used to check to see if the resource being requested is available for the authenticated user( r- user and r- ap auth type).It runs after the access checker and check user id hooks.Note that it will only be called if Apache determines that access control has been applied to this resource(through a ’Require’ directive).1.3.5 run check user idRun the authorization phase. rc r- run check user id();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00This hook is used to analyze the request headers, authenticate the user, and set the user information in therequest record ( r- user and r- ap auth type).15 Feb 20145

1.3.6 run fixupsThis hook is only run when Apache determines that authentication/authorization is required for thisresource (as determined by the ’Require’ directive).It runs after the access checker hook, and before the auth checker hook.1.3.6 run fixupsRun the fixup phase. rc r- run fixups();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00This phase allows modules to perform module-specific fixing of HTTP header fields. This is invoked justbefore the response phase.1.3.7 run handlerRun the response phase. rc r- run handler();obj: r ( Apache2::RequestRec object )The request recret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00run handler() is called internally by invoke handler(). Use run handler() only if youwant to bypass the extra functionality provided by invoke handler().615 Feb 2014

Apache2::HookRun - Perl API for Invoking Apache HTTP phases1.3.8 run header parser1.3.8 run header parserRun the header parser phase. rc r- run header parser();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )Apache2::Const::OK or Apache2::Const::DECLINED.since: 2.0.001.3.9 run log transactionRun the logging phase. rc r- run log transaction();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00This hook allows modules to perform any module-specific logging activities over and above the normalserver things.1.3.10 run map to storageRun the map to storage phase. rc r- run map to storage();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )15 Feb 20147

1.3.11 run post read requestApache2::Const::DONE (or Apache2::HTTP *) if this contextless request was just hecoremap to storage(Apache2::HOOK RUN LAST) will directory walk() and file walk() the r- filename (all internal C functions).since: 2.0.00This phase allows modules to set the per dir config based on their own context (such as Proxy sections) and responds to contextless requests such as TRACE that need no security or filesystem mappingbased on the filesystem.1.3.11 run post read requestRun the post read request phase. rc r- run post read request();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK orApache2::Const::DECLINED.since: 2.0.00This phase is run right after read request() or internal redirect(), and not run during anysubrequests. This hook allows modules to affect the request immediately after the request has been read,and before any other phases have been processes. This allows modules to make decisions based upon theinput header fields1.3.12 run translate nameRun the translate phase. rc r- run translate name();obj: r ( Apache2::RequestRec object )The current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .815 Feb 2014

Apache2::HookRun - Perl API for Invoking Apache HTTP phases1.4 See Alsosince: 2.0.00This phase gives modules an opportunity to translate the URI into an actual filename. If no modules doanything special, the server’s default rules will be applied.1.3.13 run type checkerRun the type checker phase. rc r- run type checker();obj: r ( Apache2::RequestRec object )the current requestret: rc ( integer )The status of the current phase run: Apache2::Const::OK, Apache2::Const::DECLINED,Apache2::HTTP .since: 2.0.00This phase is used to determine and/or set the various document type information bits, likeContent-type (via r- content type), language, etc.1.4 See Alsomod perl 2.0 documentation.1.5 Copyrightmod perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.1.6 AuthorsThe mod perl development team and numerous contributors.15 Feb 20149

Apache2::HookRun - Perl API for Invoking Apache HTTP phasesTable of Contents:Table of Contents:1 Apache2::HookRun - Perl API for Invoking Apache HTTP phases1.1 Synopsis .1.2 Description .1.3 API.1.3.1 die .1.3.2 invoke handler .1.3.3 run access checker .1.3.4 run auth checker .1.3.5 run check user id .1.3.6 run fixups .1.3.7 run handler .1.3.8 run header parser .1.3.9 run log transaction .1.3.10 run map to storage .1.3.11 run post read request .1.3.12 run translate name .1.3.13 run type checker .1.4 See Also .1.5 Copyright .1.6 Authors.15 Feb 2014.12333445566777889999i

Using this API you could probably also change the normal Apache behavior (e.g. invoking some hooks earlier than normal, or later), but before doing that you will probably need to spend some time reading through the Apache C code. That’s why some of the methods in this document, point you to the specific functions in the Apache source code. If you just try to use the methods from this module .

Related Documents:

Why Perl? Perl is built around regular expressions -REs are good for string processing -Therefore Perl is a good scripting language -Perl is especially popular for CGI scripts Perl makes full use of the power of UNIX Short Perl programs can be very short -"Perl is designed to make the easy jobs easy,

Other Perl resources from O’Reilly Related titles Learning Perl Programming Perl Advanced Perl Programming Perl Best Practices Perl Testing: A Developer’s . Intermedi

Run Perl Script Option 3: Create a Perl script my_script.pl: Run my_script.pl by calling perl: 8/31/2017 Introduction to Perl Basics I 10 print Hello World!\n; perl ./my_script.pl Option 4: For a small script with several lines, you can run it directly on the command line: perl -e print Hello World!\n;

Perl's creator, Larry Wall, announced it the next day in his State of the Onion address. Most notably, he said "Perl 6 is going to be designed by the community." Everyone thought that Perl 6 would be the version after the just-released Perl v5.6. That didn't happen, but that's why "Perl" was in the name "Perl 6."

Perl is an Open Source software, licensed under its Artistic License, or the GNU General Public License (GPL). Perl was created by Larry Wall. Perl 1.0 was released to usenet's alt.comp.sources in 1987. At the time of writing this tutorial, the latest version of perl was 5.16.2. Perl is listed in the Oxford English Dictionary.

1.4 Where to Get Perl 6 1.4.1 CPAN (cpan.org) 6 1.4.2 Downloads and Other Resources for Perl (perl.org) 7 1.4.3 ActivePerl (activestate.com) 8 1.4.4 What Version Do I Have? 9 1.5 Perl Documentation 9 1.5.1 Where to Find the Most Complete Documentation from Perl 9 1.5.2 Perl man Pages 10 1.5.3 Online Documentation 12

HP PHP PHP PHP PHP PHP HiPE Erlang HiPE Erlang HiPE . Perl Perl Perl Perl Perl Perl Ruby Ruby Ruby Ruby Ruby Python 3 Python 3 Python 3 Lua Lua Lua Lua Lua Lua Ruby Matz's Ruby Matz's Ruby benchmarks game 01 Mar 2019 u64q p r o . Python configures and steers fast C/C /Fortran code Passes memory buffers from one library to the next

2019) such as the Yomiyasusa Level (YL) created by Furukawa in 2003 and the international 20-level Extensive Reading Foundation (ERF) graded reader scale that has been developed by Waring since 2016 (Brierley et al., 2019). However, the first comprehensive scale for measuring reading level was the EPER scale developed by Hill in the 1970s together with a directory of graded readers and ratings .