10.6. Processing Requests

Now that we've covered Apache's major data types and the API for manipulating them, we turn to the functions you'll use routinely within your handlers to process the incoming request and produce a response.

10.6.1. Getting Information About the Transaction

You can get most of the information about the incoming request by reading it from the request record, server record, or connection record. The exception to this rule are a handful of routines that require active participation on the part of Apache to recover information about the remote host and user.

These calls are declared in the header file http_core.h unless specified otherwise:

const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type)

This routine returns the DNS name or dotted IP address of the remote host. The first argument is a pointer to the connection record, usually recovered from the request record. The second argument points to the per-directory configuration record, which can also be retrieved from the request record. ap_get_remote_host() uses the directory configuration pointer to examine the value of the HostnameLookups directive. If you pass NULL for this argument, ap_get_remote_host() will assume a value of Off for HostnameLookups, returning the dotted IP address of the remote host.

The third argument passed to ap_get_remote_host() is an integer constant indicating the type of lookup you wish to perform. There are four possibilities:


If this argument ...

Get Writing Apache Modules with Perl and C now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.