Commit 4f1f6d32 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Enable logging a cookie with mod_log_config

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
parent 4b20a68d
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -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'
    }