 IT Service Management Consultants
|
|
|
Home > Perl > Perl and Apache > mod_perl Part 3: Handlers and Filters
|
|
|
|
|
|
mod_perl Part 3: Handlers and Filters |
|
Written by Philip L Yuson
|
Who is this for
This article is for those who want to know the different mod_perl handlers and how these are used.
What
you need to know You need to know Apache configuration,
mod_perl basics and Perl
Introduction mod_perl
allows you to extend the Apache web server to process your specific
requirements. This is done in Apache by having specific 'exit-points'
in strategically placed stages of a request. By creating handlers in
these specific points, you can change the way Apache handlers your
transcations.
Handlers Handlers can execute on
server startup and at different stages in a transaction life
cycle. We will mostly be more interested in transaction handlers
specifically:
This
handler executes when a request is received and all headers have been
parsed. It executes only once in a transaction's life. You can change
the headers that you received at this point, before the transcation
is processed further.
PerlTransHandler This executes
when Apache translates the URI to a file on the server. This can be
used to change the URI or the request method. If you made significant
changes to your website file structure, you can use this to translate
the URIs to your old website to a newer one.
PerlAccessHandler If
you want to implement a policy so that certain portions of your
website is restricted to specific users, time or IP addresses, you
can use this handler. It executes only once in the transaction. Your
handler should return an Apache::FORBIDDEN or
Apache::OK.
PerlAuthenHandler You can use this to
replace Apache authentication. If this returns an
Apache::HTTP_UNAUTHORIZED return code, the browser normally pops up a
login window.
PerlResponseHandler This handler can
generate specific responses based on the URI inputted. You can change
the outgoing header and even the entire page.
PerlLogHandler This
handler allows you to improve logging. You can use this to write log
information onto a database.
Filters mod_perl 2.0
has filters. These filters allow you to have more control of the
headers and pages in a transaction. You can use this to add or remove
headers. You also use this to change contents in your response
pages.
There are two filters: PerlInputFilterHandler and
PerlOutputFilterHandler.
The PerlInputFilterHandler is executed when
the request is received.
The PerlOutputFilterHandler is executed
before a page is sent back to the browser.
To know more about mod_perl
Handlers, please read the mod_perl
2.0 or mod_perl
1.0 documentation.
|
Add comment
|
|
Copyright: © 2012 Concept Solutions Corporation
|