FREE Delivery in the UK.
Only 1 left in stock (more on the way).
Dispatched from and sold by Amazon. Gift-wrap available.
Writing Apache Modules wi... has been added to your Basket

Dispatch to:
To see addresses, please
Or
Please enter a valid UK postcode.
Or
+ £2.80 UK delivery
Used: Good | Details
Sold by Greener_Books
Condition: Used: Good
Comment: **SHIPPED FROM UK** We believe you will be completely satisfied with our quick and reliable service. All orders are dispatched as swiftly as possible! Buy with confidence!
Have one to sell?
Flip to back Flip to front
Listen Playing... Paused   You're listening to a sample of the Audible audio edition.
Learn more
See all 2 images

Writing Apache Modules with Perl and C: The Apache API and mod_perl: Customizing Your Web Server Paperback – 11 Apr 1999

4.7 out of 5 stars 3 customer reviews

See all 3 formats and editions Hide other formats and editions
Amazon Price
New from Used from
Paperback
"Please retry"
£28.50
£20.81 £1.95
Note: This item is eligible for click and collect. Details
Pick up your parcel at a time and place that suits you.
  • Choose from over 13,000 locations across the UK
  • Prime members get unlimited deliveries at no additional cost
How to order to an Amazon Pickup Location?
  1. Find your preferred location and add it to your address book
  2. Dispatch to this address when you check out
Learn more
£28.50 FREE Delivery in the UK. Only 1 left in stock (more on the way). Dispatched from and sold by Amazon. Gift-wrap available.
click to open popover

Special offers and product promotions

Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.

  • Apple
  • Android
  • Windows Phone

To get the free app, enter your mobile phone number.



Product details

  • Paperback: 750 pages
  • Publisher: O'Reilly Media; 1 edition (11 April 1999)
  • Language: English
  • ISBN-10: 156592567X
  • ISBN-13: 978-1565925670
  • Product Dimensions: 17.8 x 3.1 x 23.3 cm
  • Average Customer Review: 4.7 out of 5 stars  See all reviews (3 customer reviews)
  • Amazon Bestsellers Rank: 773,598 in Books (See Top 100 in Books)
  • If you are a seller for this product, would you like to suggest updates through seller support?

  • See Complete Table of Contents

Product description

About the Author

Doug MacEachern has been addicted to Perl and web servers since early 1994 when he was introduced to Plexus as a student employee at the University of Arizona. Soon after returning to his home town of Boston, Massachusetts, and entering the "real world," he discovered the Apache web server, and since early 1996, he has been gluing Perl into all its nooks and crannies. His day job has consisted of integrating various other technologies with the Web, including DCE, Kerberos, and GSSAPI, but Perl has been the only one he cannot let go of. Doug has continued as a developer disguised as a consultant since the start of 1998, spending most of his time between Auckland, New Zealand, and San Francisco, California, with time at home in Boston during the warmer months. Doug likes to spend his time away from software--far, far away, sailing on the ocean, diving below it, or simply looking at it from a warm, sandy beach where technology doesn't go much beyond thatched huts and blenders.

Lincoln Stein is an assistant investigator at Cold Spring Harbor Laboratory, where he develops databases and user interfaces for the Human Genome Project using the Apache server and its module API. He is the author of several books about programming for the Web, including The Official Guide to CGI.pm, How to Set Up and Maintain a Web Site, and Web Security: A Step-by-Step Reference Guide.

Excerpt. © Reprinted by permission. All rights reserved.

Chapter 4 - Content Handlers

In this chapter:
Content Handlers as File Processors
Virtual Documents
Redirection
Processing Input
Apache::Registry
Handling Errors
Chaining Content Handlers
Method Handlers

This chapter is about writing content handlers for the Apache response phase, when the contents of the page are actually produced. In this chapter you'll learn how to produce dynamic pages from thin air, how to modify real documents on the fly to produce effects like server-side includes, and how Apache interacts with the MIME-typing system to select which handler to invoke.

Starting with this chapter we shift to using the Apache Perl API exclusively for code examples and function prototypes. The Perl API covers the majority of what C programmers need to use the C-language API. What's missing are various memory management functions that are essential to C programmers but irrelevant in Perl. If you are a C programmer, just have patience and the missing pieces will be filled in eventually. In the meantime, follow along with the Perl examples and enjoy yourself. Maybe you'll even become a convert.

Content Handlers as File Processors
Early web servers were designed as engines for transmitting physical files from the host machine to the browser. Even though Apache does much more, the file-oriented legacy still remains. Files can be sent to the browser unmodified or passed through content handlers to transform them in various ways before sending them on to the browser. Even though many of the documents that you produce with modules have no corresponding physical files, some parts of Apache still behave as if they did.

When Apache receives a request, the URI is passed through any URI translation handlers that may be installed (see Chapter 7, Other Request Phases, for information on how to roll your own), transforming it into a file path. The mod_alias translation handler (compiled in by default) will first process any Alias, ScriptAlias, Redirect, or other mod_alias directives. If none applies, the http_core default translator will simply prepend the DocumentRoot directory to the beginning of the URI.

Next, Apache attempts to divide the file path into two parts: a "filename" part which usually (but not always) corresponds to a physical file on the host's filesystem, and an "additional path information" part corresponding to additional stuff that follows the filename. Apache divides the path using a very simple-minded algorithm. It steps through the path components from left to right until it finds something that doesn't correspond to a directory on the host machine. The part of the path up to and including this component becomes the filename, and everything that's left over becomes the additional path information.

Consider a site with a document root of /home/www that has just received a request for URI /abc/def/ghi. The way Apache splits the file path into filename and path information parts depends on what directories it finds in the document root:

Note that the presence of any actual files in the path is irrelevant to this process. The division between the filename and the path information depends only on what directories are present.

Once Apache has decided where the file is in the path, it determines what MIME type it might be. This is again one of the places where you can intervene to alter the process with a custom type handler. The default type handler (mod_mime) just compares the filename's extension to a table of MIME types. If there's a match, this becomes the MIME type. If no match is found, then the MIME type is undefined. Again, note that this mapping from filename to MIME type occurs even when there's no actual file there.

There are two special cases. If the last component of the filename happens to be a physical directory, then Apache internally assigns it a "magic" MIME type, defined by the DIR_MAGIC_TYPE constant as httpd/unix-directory. This is used by the directory module to generate automatic directory listings. The second special case occurs when you have the optional mod_mime_magic module installed and the file actually exists. In this case Apache will peek at the first few bytes of the file's contents to determine what type of file it might be. Chapter 7 shows you how to write your own MIME type checker handlers to implement more sophisticated MIME type determination schemes.

After Apache has determined the name and type of the file referenced by the URI, it decides what to do about it. One way is to use information hard-wired into the module's static data structures. The module's handler_rec table, which we describe in detail in Chapter 10, C API Reference Guide, Part I, declares the module's willingness to handle one or more magic MIME types and associates a content handler with each one. For example, the mod_cgi module associates MIME type application/x-httpd-cgi with its cgi_handler( ) handler subroutine. When Apache detects that a filename is of type application/x-httpd-cgi it invokes cgi_handler( ) and passes it information about the file. A module can also declare its desire to handle an ordinary MIME type, such as video/quicktime, or even a wildcard type, such as video/*. In this case, all requests for URIs with matching MIME types will be passed through the module's content handler unless some other module registers a more specific type.


Customer reviews

4.7 out of 5 stars
5 star
2
4 star
1
3 star
0
2 star
0
1 star
0
Share your thoughts with other customers
See all 3 customer reviews

Top customer reviews

on 20 August 1999
Format: Paperback
0Comment| 3 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 22 October 2001
Format: Paperback
0Comment| One person found this helpful. Was this review helpful to you?YesNoReport abuse
on 8 October 2015
Format: Paperback|Verified Purchase
0Comment|Was this review helpful to you?YesNoReport abuse

Most helpful customer reviews on Amazon.com

Amazon.com: 4.5 out of 5 stars 23 reviews
5.0 out of 5 starsbest $2.00 I ever spent!
on 26 May 2006 - Published on Amazon.com
Format: Paperback|Verified Purchase
One person found this helpful.
3.0 out of 5 starsOutdated, but still helpful
on 23 January 2007 - Published on Amazon.com
Format: Paperback|Verified Purchase
17 people found this helpful.
5.0 out of 5 starsThe essence of O'Reilly
on 21 April 1999 - Published on Amazon.com
Format: Paperback
10 people found this helpful.
4.0 out of 5 starsTarzan like book, shiny..., book marry Tarzan?
on 13 May 1999 - Published on Amazon.com
Format: Paperback
16 people found this helpful.
5.0 out of 5 starsA web programming marvel
on 18 October 2001 - Published on Amazon.com
Format: Paperback
Pages with related products. See and discover other items: api programming