httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/loggers mod_log_config.c
Date Sat, 10 Apr 2004 17:48:52 GMT
nd          2004/04/10 10:48:52

  Modified:    .        CHANGES
               modules/loggers mod_log_config.c
  Log:
  cleanup log_header_out function:
  - no need to ask r->err_headers_out, because it's already merged with
    r->headers_out at this stage
  - allow multiple headers like Set-Cookie to be logged properly
  
  PR: 27787
  
  Revision  Changes    Path
  1.1452    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1451
  retrieving revision 1.1452
  diff -u -u -r1.1451 -r1.1452
  --- CHANGES	10 Apr 2004 13:57:38 -0000	1.1451
  +++ CHANGES	10 Apr 2004 17:48:52 -0000	1.1452
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) mod_log_config now logs all Set-Cookie headers if the %{Set-Cookie}o
  +     format is used.  PR 27787.  [André Malo]
  +
     *) Fix a bunch of cases where the return code of the regex compiler
        was not checked properly. This affects: mod_setenvif, mod_usertrack,
        mod_proxy, mod_proxy_ftp and core. PR 28218.  [André Malo]
  
  
  
  1.116     +75 -4     httpd-2.0/modules/loggers/mod_log_config.c
  
  Index: mod_log_config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/loggers/mod_log_config.c,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -u -r1.115 -r1.116
  --- mod_log_config.c	26 Feb 2004 20:15:26 -0000	1.115
  +++ mod_log_config.c	10 Apr 2004 17:48:52 -0000	1.116
  @@ -403,16 +403,87 @@
       return ap_escape_logitem(r->pool, apr_table_get(r->headers_in, a));
   }
   
  +static APR_INLINE char *find_multiple_headers(apr_pool_t *pool,
  +                                              const apr_table_t *table,
  +                                              const char *key)
  +{
  +    const apr_array_header_t *elts;
  +    const apr_table_entry_t *t_elt;
  +    const apr_table_entry_t *t_end;
  +    apr_size_t len;
  +    struct sle {
  +        struct sle *next;
  +        const char *value;
  +        apr_size_t len;
  +    } *result_list, *rp;
  +
  +    elts = apr_table_elts(table);
  +
  +    if (!elts->nelts) {
  +        return NULL;
  +    }
  +
  +    t_elt = (const apr_table_entry_t *)elts->elts;
  +    t_end = t_elt + elts->nelts;
  +    len = 1; /* \0 */
  +    result_list = rp = NULL;
  +
  +    do {
  +        if (!strcasecmp(t_elt->key, key)) {
  +            if (!result_list) {
  +                result_list = rp = apr_palloc(pool, sizeof(*rp));
  +            }
  +            else {
  +                rp = rp->next = apr_palloc(pool, sizeof(*rp));
  +                len += 2; /* ", " */
  +            }
  +
  +            rp->next = NULL;
  +            rp->value = t_elt->val;
  +            rp->len = strlen(rp->value);
  +
  +            len += rp->len;
  +        }
  +        ++t_elt;
  +    } while (t_elt < t_end);
  +
  +    if (result_list) {
  +        char *result = apr_palloc(pool, len);
  +        char *cp = result;
  +
  +        rp = result_list;
  +        while (rp) {
  +            if (rp != result_list) {
  +                *cp++ = ',';
  +                *cp++ = ' ';
  +            }
  +            memcpy(cp, rp->value, rp->len);
  +            cp += rp->len;
  +            rp = rp->next;
  +        }
  +        *cp = '\0';
  +
  +        return result;
  +    }
  +
  +    return NULL;
  +}
  +
   static const char *log_header_out(request_rec *r, char *a)
   {
  -    const char *cp = apr_table_get(r->headers_out, a);
  +    const char *cp = NULL;
  +
       if (!strcasecmp(a, "Content-type") && r->content_type) {
           cp = ap_field_noparam(r->pool, r->content_type);
       }
  -    if (cp) {
  -        return ap_escape_logitem(r->pool, cp);
  +    else if (!strcasecmp(a, "Set-Cookie")) {
  +        cp = find_multiple_headers(r->pool, r->headers_out, a);
  +    }
  +    else {
  +        cp = apr_table_get(r->headers_out, a);
       }
  -    return ap_escape_logitem(r->pool, apr_table_get(r->err_headers_out, a));
  +
  +    return ap_escape_logitem(r->pool, cp);
   }
   
   static const char *log_note(request_rec *r, char *a)
  
  
  

Mime
View raw message