O'Reilly logo

Writing Apache Modules with Perl and C by Lincoln Stein, Doug MacEachern

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

REMOTE_HOST

If this argument ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required