Request Information Connection Information
$r->method( [$meth] ) = <% $r->method() %>
$r->method_number( [$num] ) = <% $r->method_number() %>
$r->bytes_sent = <% $r->bytes_sent %>
$r->the_request = <% $r->the_request %>
$r->proxyreq = <% $r->proxyreq %>
$r->header_only = <% $r->header_only %>
$r->protocol = <% $r->protocol %>
$r->uri( [$uri] ) = <% $r->uri() %>
$r->filename( [$filename] ) = <% $r->filename() %>
$r->path_info( [$path_info] ) = <% $r->path_info() %>
$r->args = <% $r->args %>
$r->header_in( $header_name, [$value] ) = <% $r->header_in("Content-type") %>
$r->get_remote_host = <% $r->get_remote_host %>
$r->requires = <% $r->requires %>
$r->auth_type = <% $r->auth_type %>
$r->auth_name = <% $r->auth_name %>
$r->document_root = <% $r->document_root %>
$r->allow_options = <% $r->allow_options %>
% my $c = $r->connection; $c->remote_host = <%$c->remote_host%>
$c->remote_ip = <%$c->remote_ip %>
$c->local_addr = <%$c->local_addr %>
$c->remote_addr = <%$c->remote_addr %>
$c->remote_logname = <%$c->remote_logname%>
$c->user = <%$c->user %>
$c->auth_type = <%$c->auth_type %>
$c->aborted = <%$c->aborted %>
Server Configuration
% my $s = $r->server; $s->server_admin = <% $s->server_admin %>
$s->server_hostname = <%$s->server_hostname%>
$s->port = <%$s->port%>
$s->is_virtual = <%$s->is_virtual%>
$s->names = <%$s->names%>

$r->method( [$meth] )

The $r->method method will return the request method. It will be a string such as ``GET'', ``HEAD'' or ``POST''. Passing an argument will set the method, mainly used for internal redirects.
$r->method_number( [$num] )
The $r->method_number method will return the request method number. The method numbers are defined by the M_GET, M_POST,... constants available from the Apache::Constants module. Passing an argument will set the method_number, mainly used for internal redirects and testing authorization restriction masks.
$r->bytes_sent
The number of bytes sent to the client, handy for logging, etc.
$r->the_request
The request line send by the client, handy for logging, etc.
$r->proxyreq
Returns true if the request is proxy http. Mainly used during the filename translation stage of the request, which may be handled by a PerlTransHandler.
$r->header_only
Returns true if the client is asking for headers only, e.g. if the request method was HEAD.
$r->protocol
The $r->protocol method will return a string identifying the protocol that the client speaks. Typical values will be ``HTTP/1.0'' or ``HTTP/1.1''.
$r->uri( [$uri] )
The $r->uri method will return the requested URI, optionally changing it with the first argument.
$r->filename( [$filename] )
The $r->filename method will return the result of the URI --> filename translation, optionally changing it with the first argument if you happen to be doing the translation.
$r->path_info( [$path_info] )
The $r->path_info method will return what is left in the path after the URI --> filename translation, optionally changing it with the first argument if you happen to be doing the translation.
$r->args
The $r->args method will return the contents of the URI query string. When called in a scalar context, the entire string is returned. When called in a list context, a list of parsed key => value pairs are returned, i.e. it can be used like this:
   $query = $r->args;
   %in    = $r->args;
<%doc>
$r->headers_in The $r->headers_in method will return a %hash of client request headers. This can be used to initialize a perl hash, or one could use the $r->header_in() method (described below) to retrieve a specific header value directly. $r->header_in( $header_name, [$value] )
Return the value of a client header. Can be used like this:
   $ct = $r->header_in("Content-type");
   $r->header_in($key, $val); #set the value of header '$key'
$r->content
The $r->content method will return the entity body read from the client, but only if the request content type is application/x-www-form-urlencoded. When called in a scalar context, the entire string is returned. When called in a list context, a list of parsed key => value pairs are returned. *NOTE*: you can only ask for this once, as the entire body is read from the client.
$r->read_client_block($buf, $bytes_to_read) Read from the entity body sent by the client. Example of use: $r->read_client_block($buf, $r->header_in('Content-length')); $r->get_remote_host= <% $r->get_remote_host %>
Lookup the client's DNS hostname. If the configuration directive HostNameLookups is set to off, this returns the dotted decimal representation of the client's IP address instead. Might return undef if the hostname is not known.
$r->get_remote_logname = NOT IMPLEMENTED BY MOD_PERL
Lookup the remote user's system name. Might return undef if the remote system is not running an RFC 1413 server or if the configuration directive IdentityCheck is not turned on.
More information about the client can be obtained from the Apache::Connection object, as described below.

$c = $r->connection

The $r->connection method will return a reference to the request connection object (blessed into the Apache::Connection package). This is really a conn_rec* in disguise. The following methods can be used on the connection object:
$c->remote_host
If the configuration directive HostNameLookups is set to on: then the first time $r->get_remote_host is called the server does a DNS lookup to get the remote client's host name. The result is cached in $c->remote_host then returned. If the server was unable to resolve the remote client's host name this will be set to ``''. Subsequent calls to $r->get_remote_host return this cached value.

If the configuration directive HostNameLookups is set to off: calls to $r->get_remote_host return a string that contains the dotted decimal representation of the remote client's IP address. However this string is not cached, and $c->remote_host is undefined. So, it's best to to call $r->get_remote_host instead of directly accessing this variable.

$c->remote_ip
The dotted decimal representation of the remote client's IP address. This is set by then server when the connection record is created so is always defined.
$c->local_addr
A packed SOCKADDR_IN in the same format as returned by Socket, containing the port and address on the local host that the remote client is connected to. This is set by the server when the connection record is created so it is always defined.
$c->remote_addr
A packed SOCKADDR_IN in the same format as returned by Socket, containing the port and address on the remote host that the server is connected to. This is set by the server when the connection record is created so it is always defined.

Among other things, this can be used, together with $c->local_addr, to perform RFC1413 ident lookups on the remote client even when the configuration directive IdentityCheck is turned off.

Can be used like:

   use Net::Ident qw (lookupFromInAddr);
   ...
   my $remoteuser = lookupFromInAddr ($c->local_addr,
  $c->remote_addr, 2);
Note that the lookupFromInAddr interface does not currently exist in the Net::Ident module, but the author is planning on adding it soon.
$c->remote_logname
If the configuration directive IdentityCheck is set to on: then the first time $r->get_remote_logname is called the server does an RFC 1413 (ident) lookup to get the remote users system name. Generally for UNI* systems this is their login. The result is cached in $c->remote_logname then returned. Subsequent calls to $r->get_remote_host return the cached value.

If the configuration directive IdentityCheck is set to off: then $r->get_remote_logname does nothing and $c->remote_logname is always undefined.

$c->user
If an authentication check was successful, the authentication handler caches the user name here.
$c->auth_type
Returns the authentication scheme that successfully authenticate $c->user, if any.
$c->aborted
Returns true if the client stopped talking to us.

SERVER CONFIGURATION INFORMATION

The following methods are used to obtain information from server configuration and access control files.
$r->dir_config( $key )
Returns the value of a per-directory variable specified by the PerlSetVar directive.
   # 
   # SetPerlVar  Key  Value
   # 

   my $val = $r->dir_config('Key');

$r->requires
Returns an array reference of hash references, containing information related to the require directive. This is normally used for access control, see Apache for an example.
$r->auth_type
Returns a reference to the current value of the per directory configuration directive AuthType. Normally this would be set to Basic to use the basic authentication scheme defined in RFC 1945, Hypertext Transfer Protocol -- HTTP/1.0. However, you could set to something else and implement your own authentication scheme.
$r->auth_name
Returns a reference to the current value of the per directory configuration directive AuthName. The AuthName directive creates protection realm within the server document space. To quote RFC 1945 ``These realms allow the protected resources on a server to be partitioned into a set of protection spaces, each with its own authentication scheme and/or authorization database.'' The client uses the root URL of the server to determine which authentication credentials to send with each HTTP request. These credentials are tagged with the name of the authentication realm that created them. Then during the authentication stage the server uses the current authentication realm, from $r->auth_name, to determine which set of credentials to authenticate.
$r->document_root
Returns a reference to the current value of the per server configuration directive DocumentRoot. To quote the Apache server documentation, ``Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document.'' This same value is passed to CGI scripts in the DOCUMENT_ROOT environment variable.
$r->allow_options
The $r->allow_options method can be used for checking if it is OK to run a perl script. The Apache::Options module provides the constants to check against.
   if(!($r->allow_options & OPT_EXECCGI)) {
 $r->log_reason("Options ExecCGI is off in this directory", 
    $filename);
   }
$s = $r->server
Return a reference to the server info object (blessed into the Apache::Server package). This is really a server_rec* in disguise. The following methods can be used on the server object:
$s = Apache->server
Same as above, but only available during server startup for use in sections, PerlScript or PerlModule.
$s->server_admin
Returns the mail address of the person responsible for this server.
$s->server_hostname
Returns the hostname used by this server.
$s->port
Returns the port that this servers listens too.
$s->is_virtual
Returns true if this is a virtual server.
$s->names
Returns the wild-carded names for HostAlias servers.
$s->warn
Alias for Apache::warn.
$s->log_error
Alias for Apache::log_error.