httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sander van Zoest <san...@covalent.net>
Subject [PATCH] Re: mod_log_config: Cookie logging patch 1.3.X
Date Wed, 06 Dec 2000 22:55:36 GMT
On Mon, 20 Nov 2000, Sander van Zoest wrote:
> On Fri, 17 Nov 2000, Sander van Zoest wrote:
> > in <20000803122854.P28576@sung4.rd.bbc.co.uk>,
> > <http://archive.covalent.net/new-httpd/2000/08/0036.xml> Erik Meyer
> > posted a patch to mod_log_config that would use the %{cookie}c to log
> > specific cookies. PR#6418 has a similar patch.
> Below find the patch for HEAD + docs for apache 1.3 and 2.0 to add this
> functionality. Let me know what else you need to get this committed.

The new %{FOOBAR}C cookie functionality got added to 2.0, but most people 
would want this functionality for 1.3.15 when it comes out.

I understand the reasoning why not to include a new "feature" in 1.3, 
but meanwhile  %c is also new for 1.3.15, so that pretty much kills the
argument for me. :-)

Cheers,

--
Sander van Zoest                                         [sander@covalent.net]
Covalent Technologies, Inc.                           http://www.covalent.net/
(415) 536-5218                                 http://www.vanzoest.com/sander/
  
Index: apache-1.3/src/modules/standard/mod_log_config.c
===================================================================
RCS file: /work/cvs/root/asf/httpd/apache-1.3/src/modules/standard/mod_log_config.c,v
retrieving revision 1.85
diff -u -r1.85 mod_log_config.c
--- apache-1.3/src/modules/standard/mod_log_config.c	2000/11/14 09:57:22	1.85
+++ apache-1.3/src/modules/standard/mod_log_config.c	2000/11/18 02:59:48
@@ -124,6 +124,7 @@
  *         '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
@@ -412,6 +413,26 @@
     return ap_table_get(r->subprocess_env, a);
 }
 
+static const char *log_cookie(request_rec *r, char *a)
+{
+  const char *cookies;
+  char *start_cookie;
+
+  if((cookies = ap_table_get(r->headers_in, "Cookie"))) 
+    if(( start_cookie = strstr(cookies,a))) 
+    {
+      char *cookie, *end_cookie;
+      start_cookie += strlen(a) + 1; /* cookie_name + '=' */
+      cookie = ap_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)
 {
     int timz;
@@ -566,6 +587,9 @@
     },
     {
         'c', log_connection_status, 0
+    },
+    {
+        'C', log_cookie, 0
     },
     {
         '\0'
Index: docs-1.3/htdocs/manual/mod/mod_log_config.html
===================================================================
RCS file: /work/cvs/root/asf/httpd/docs-1.3/htdocs/manual/mod/mod_log_config.html,v
retrieving revision 1.40
diff -u -r1.40 mod_log_config.html
--- docs-1.3/htdocs/manual/mod/mod_log_config.html	2000/11/13 02:01:35	1.40
+++ docs-1.3/htdocs/manual/mod/mod_log_config.html	2000/11/20 20:55:34
@@ -159,6 +159,8 @@
                 '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 cookie "Foobar" in the request sent to the
+                server.
 %...{FOOBAR}e:  The contents of the environment variable FOOBAR
 %...f:          Filename
 %...h:          Remote host



Mime
View raw message