From: Ryan Bloom Date: Thu, 30 Nov 2000 00:31:03 +0000 (+0000) Subject: Enable logging a cookie with mod_log_config X-Git-Tag: moving_to_httpd_module~30 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f98dcb99c587d8e2bd0f5d6173512a8aeeea4dcf;p=apache Enable logging a cookie with mod_log_config Submitted by: Sander van Zoest git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87136 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index f052df93f1..e4b036fda9 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -125,6 +125,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 @@ -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' }