]> granicus.if.org Git - apache/commitdiff
Enable logging a cookie with mod_log_config
authorRyan Bloom <rbb@apache.org>
Thu, 30 Nov 2000 00:31:03 +0000 (00:31 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 30 Nov 2000 00:31:03 +0000 (00:31 +0000)
Submitted by: Sander van Zoest <sander@covalent.net>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87136 13f79535-47bb-0310-9956-ffa450edef68

modules/loggers/mod_log_config.c

index f052df93f187566d19e0bda27cc5367634af2a54..e4b036fda9037b770af88557199a8e4fde237fe6 100644 (file)
  *         'X' = connection aborted before the response completed.
  *         '+' = connection may be kept alive after the response is sent.
  *         '-' = connection will be closed after the response is sent.
+ * %...{FOOBAR}C:  The contents of the HTTP cookie FOOBAR
  * %...{FOOBAR}e:  The contents of the environment variable FOOBAR
  * %...f:  filename
  * %...h:  remote host
@@ -415,6 +416,27 @@ static const char *log_env_var(request_rec *r, char *a)
     return apr_table_get(r->subprocess_env, a);
 }
 
+static const char *log_cookie(request_rec *r, char *a)
+{
+    const char *cookies;
+    const char *start_cookie;
+
+    if ((cookies = apr_table_get(r->headers_in, "Cookie"))) {
+        if ((start_cookie = ap_strstr_c(cookies,a))) {
+            char *cookie, *end_cookie;
+            start_cookie += strlen(a) + 1; /* cookie_name + '=' */
+            cookie = apr_pstrdup(r->pool, start_cookie);
+            /* kill everything in cookie after ';' */
+            end_cookie = strchr(cookie, ';'); 
+            if (end_cookie) {
+                *end_cookie = '\0';
+            }
+            return cookie;
+        }
+    }
+    return NULL;
+}
+
 static const char *log_request_time(request_rec *r, char *a)
 {
     apr_exploded_time_t xt;
@@ -592,6 +614,9 @@ static struct log_item_list {
     {
         'c', log_connection_status, 0
     },
+    {
+        'C', log_cookie, 0
+    },
     {
         '\0'
     }