Project

General

Profile

cookie.log.patch.txt

snailfly, 2007-04-24 18:04

 
1
Index: mod_accesslog.c
2
===================================================================
3
--- src/mod_accesslog.c	(revision 1820)
4
+++ src/mod_accesslog.c	(working copy)
5
@@ -622,6 +698,7 @@
6
 	plugin_data *p = p_d;
7
 	buffer *b;
8
 	size_t j;
9
+	char *g, *nc, nc2[1024]; /* for FORMAT_COOKIE*/
10
 
11
 	int newts = 0;
12
 	data_string *ds;
13
@@ -790,7 +867,10 @@
14
 				buffer_append_long(b, srv->srvconf.port);
15
 				break;
16
 			case FORMAT_QUERY_STRING:
17
+				if (con->uri.query->used) {
18
+					buffer_append_string(b, "?");
19
 				buffer_append_string_buffer(b, con->uri.query);
20
+				}
21
 				break;
22
 			case FORMAT_URL:
23
 				buffer_append_string_buffer(b, con->uri.path_raw);
24
@@ -801,6 +881,30 @@
25
 				default: buffer_append_string(b, "+"); break;
26
 				}
27
 				break;
28
+			case FORMAT_COOKIE:
29
+				if (NULL != (ds = (data_string *)array_get_element(con->request.headers, CONST_STR_LEN("Cookie"))) || NULL != (ds = (data_string *)array_get_element(con->response.headers, CONST_STR_LEN("Set-Cookie")))) {
30
+					 /* check for cookiename + (WS | '=') */
31
+				       	if (NULL != (g = strstr(ds->value->ptr, p->conf.parsed_format->ptr[j]->string->ptr))) {
32
+					       	/* skip WS  */
33
+					       	for (nc = g + p->conf.parsed_format->ptr[j]->string->used-1; *nc == ' ' || *nc == '\t'; nc++); 
34
+
35
+						/*memset(nc2, 0, sizeof(nc2)); */
36
+
37
+						if (*nc == '=') {
38
+							nc ++;
39
+							for (g = nc2; ((g-nc2) < sizeof(nc2)-1) && *nc && *nc != ';'&& *nc != ' ' && *nc != '\t'; nc++, g++)
40
+								g[0] = nc[0];
41
+							g[0] = '\0';
42
+							buffer_append_string(b, nc2);
43
+					       	} else 
44
+							BUFFER_APPEND_STRING_CONST(b, "-");
45
+				       	} else {
46
+						BUFFER_APPEND_STRING_CONST(b, "-");
47
+					}
48
+				} else {
49
+					BUFFER_APPEND_STRING_CONST(b, "-");
50
+				}
51
+				break;
52
 			default:
53
 				/*
54
 				 { 'a', FORMAT_REMOTE_ADDR },