]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r579425 from trunk:
authorEric Covener <covener@apache.org>
Thu, 8 May 2008 00:34:36 +0000 (00:34 +0000)
committerEric Covener <covener@apache.org>
Thu, 8 May 2008 00:34:36 +0000 (00:34 +0000)
mod_log_config: Add format options for %p so that the actual local
or remote port can be logged.

PR:  43415
Submitted by: Adam Hasselbalch Hansen <ahh@one.com>
Extensively commented on and/or modified by Ruediger Pluem and Jeff Trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@654348 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_log_config.xml
modules/loggers/mod_log_config.c

diff --git a/CHANGES b/CHANGES
index b3eb40d72772f3567ec01564a6712ff7c4c1a776..82cfd018fe918eccbed0b89bb621f50dd98702a0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.2.9
 
+  *) mod_log_config: Add format options for %p so that the actual local
+     or remote port can be logged.  PR 43415.  [Adam Hasselbalch Hansen
+     <ahh@one.com>, Ruediger Pluem, Jeff Trawick]
+
   *) mod_speling: remove regression from 1.3/2.0 behavior and
      drop dependency between mod_speling and AcceptPathInfo.
      PR 43562 [Jose Kahan <jose w3.org>]
index b5a7bed259c0f4a470f1e84c601ea5834a37d0a3..27c855c240d8e9de10c6097b04bfa05fce0d1c3b 100644 (file)
     <tr><td><code>%p</code></td>
         <td>The canonical port of the server serving the request</td></tr>
 
+    <tr><td><code>%{<var>format</var>}p</code></td>
+        <td>The canonical port of the server serving the request or the
+        server's actual port or the client's actual port.  Valid formats
+        are <code>canonical</code>, <code>local</code>, or <code>remote</code>.
+        </td></tr>
+
     <tr><td><code>%P</code></td>
         <td>The process ID of the child that serviced the request.</td></tr>
 
index 72bf5018597432745118c8ec936559d062b2df56..cd468be14101f2d9cd20ec80a9738db003ffc38e 100644 (file)
@@ -90,7 +90,9 @@
  * %...l:  remote logname (from identd, if supplied)
  * %...{Foobar}n:  The contents of note "Foobar" from another module.
  * %...{Foobar}o:  The contents of Foobar: header line(s) in the reply.
- * %...p:  the port the request was served to
+ * %...p:  the canonical port for the server
+ * %...{format}p: the canonical port for the server, or the actual local
+ *                or remote port
  * %...P:  the process ID of the child that serviced the request.
  * %...{format}P: the process ID or thread ID of the child/thread that
  *                serviced the request
@@ -633,8 +635,22 @@ static const char *log_virtual_host(request_rec *r, char *a)
 
 static const char *log_server_port(request_rec *r, char *a)
 {
-    return apr_psprintf(r->pool, "%u",
-                        r->server->port ? r->server->port : ap_default_port(r));
+    apr_port_t port;
+
+    if (*a == '\0' || !strcasecmp(a, "canonical")) {
+        port = r->server->port ? r->server->port : ap_default_port(r);
+    }
+    else if (!strcasecmp(a, "remote")) {
+        port = r->connection->remote_addr->port;
+    }
+    else if (!strcasecmp(a, "local")) {
+        port = r->connection->local_addr->port;
+    }
+    else {
+        /* bogus format */
+        return a;
+    }
+    return apr_itoa(r->pool, (int)port);
 }
 
 /* This respects the setting of UseCanonicalName so that