[Kc] Writing Apache Modules with Perl and C

Garrett Goebel garrett at scriptpro.com
Thu Apr 24 13:16:13 CDT 2003


Writing Apache Modules with Perl and C
Authors: Lincoln Stein, Doug MacEachern
Publisher: O'Reilly
Published: 1999-03
ISBN: 156592567X

"Writing Apache Modules with Perl and C" is an excellent introduction to the
Apache 1.X API and mod_perl. The book assumes an intermediate understanding
of Perl, but only a passing familiarity with the Hyper Text Transfer
Protocol (HTTP) and Apache. Though if you choose to read this book you won't
have only a passing familiarity for long. By the time you finish reading
this book for the first time you will have a thorough understanding of how
web servers work in general and Apache API in detail. Then you can go back
and read it again and you'll find you're still learning ;)

Admittedly the book is written to illustrate the Apache API through mod_perl
with much emphasis on "Perl". However reference and commentary on the C API
is provided in the appendices. Even though it was published in 1999 the book
is still very relevant. "mod_perl Developer's Cookbook" (ISBN: 0672322404,
published: 2003-01) which is also highly regarded, recommends "Writing
Apache Modules with Perl and C" as being "absolutely indispensable".

The book starts with a history of server-side technologies which have shaped
and influenced how Apache came to be. It follows with an introduction to
Apache walking the reader through the installation, configuration and
directives necessary to get up and running with Apache and mod_perl. And of
course it provides the gratuitous "hello world" example. During the
introduction, the authors do an excellent job of balancing UNIX and Win32, C
and Perl. The rest of the book however, gradually slides into an assumption
of UNIX and Perl.

At this point the authors begin to cover the basics of how HTTP servers
work, the Apache process' life cycle: startup, module initialization, child
initialization, request loop, child exit, and shutdown, and then continue on
with the phases of the request loop. Which assuming success is request,
post-read-request, uri translation, header parsing, access control,
authentication, authorization, mime-type checking, fixups, response,
logging, and cleanup.

They then present the Handler API. In short, a handler is a hook which
allows a programmer to modify what actually occurs at the particular phase
being handled. They proceed to describe how you can provide handlers for
each of the request phases provided by the C API and a couple available only
to under mod_perl. The authors look in considerable detail at various
illustrative scenarios for content generation handlers, maintaining state,
and the trinity of access control, authentication, and authorization.
Strictly speaking maintaining state isn't a subject tied to the Apache API.
But the coverage of session state is valuable in itself and its placement
and presentation flow naturally. 

Throughout the text, the authors illustrate various methods of addressing
issues relevant to each phase of the request loop. They highlight relative
advantages and disadvantages of various techniques and give the reader
advice on when and where each approach is appropriate. This type of advice
is absolutely invaluable. For example: when to use cookies versus shared
memory or persistent data storage in the context of browser compatibility
and security. The problems and code examples may appear to be contrived
and/or simplistic, but they server very well to teach you the why's and not
just the how's of what you need to know.

Also covered are topics such as debugging, subclassing the Apache class, and
customizing apache configuration. Throughout the book the authors mention
many of the standard Apache modules and many that are not. It is in this
area that the book begins to show its age. For instance, the authors mention
that Apache::Request will soon be released on CPAN. This module was released
back in 1999, and many current Apache modules absolutely can't work without
it.

I'm not sure whether "Practical mod_perl" which is currently due to be
released in May of 2003 is intended to supplant or augment this text. Time
will tell. But if this book is the measure, the bar will be very high
indeed. I do hope Stein and MacEachern will consider an update. And if they
do, I hope they'll add more info on performance tuning and debugging. 

--
Garrett Goebel
IS Development Specialist

ScriptPro                  Direct: 913.403.5261
5828 Reeds Road            Main:   913.384.1008
Mission, KS 66202          Fax:    913.384.2180
www.scriptpro.com          garrett at scriptpro dot com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20030424/a8c7df07/attachment.htm


More information about the kc mailing list