You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2002/02/21 07:06:31 UTC

cvs commit: httpd-2.0/modules/proxy proxy_http.c proxy_util.c

minfrin     02/02/20 22:06:31

  Modified:    .        CHANGES
               modules/proxy proxy_http.c proxy_util.c
  Log:
  Some browsers ignore cookies that have been merged into a
  single Set-Cookie header. Set-Cookie and Set-Cookie2 headers
  are now unmerged in the http proxy before being sent to the
  client.
  Fix a problem with proxy where each entry of a duplicated
  header such as Set-Cookie would overwrite and obliterate the
  previous value of the header, resulting in multiple header
  values (like cookies) going missing.
  
  Revision  Changes    Path
  1.599     +11 -0     httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.598
  retrieving revision 1.599
  diff -u -r1.598 -r1.599
  --- CHANGES	21 Feb 2002 01:30:06 -0000	1.598
  +++ CHANGES	21 Feb 2002 06:06:30 -0000	1.599
  @@ -1,5 +1,16 @@
   Changes with Apache 2.0.33-dev
   
  +  *) Some browsers ignore cookies that have been merged into a
  +     single Set-Cookie header. Set-Cookie and Set-Cookie2 headers
  +     are now unmerged in the http proxy before being sent to the
  +     client. [Graham Leggett]
  +
  +  *) Fix a problem with proxy where each entry of a duplicated
  +     header such as Set-Cookie would overwrite and obliterate the
  +     previous value of the header, resulting in multiple header
  +     values (like cookies) going missing.
  +     [Graham Leggett, Joshua Slive]
  +
     *) Add the server-limit and thread-limit values to the scoreboard
        for the sake of third-party applications.
        [Adam Sussman <my...@vishnu.vidya.com>]
  
  
  
  1.131     +7 -3      httpd-2.0/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- proxy_http.c	20 Feb 2002 20:25:15 -0000	1.130
  +++ proxy_http.c	21 Feb 2002 06:06:31 -0000	1.131
  @@ -569,21 +569,21 @@
           /* Add X-Forwarded-For: so that the upstream has a chance to
            * determine, where the original request came from.
            */
  -        apr_table_setn(r->headers_in, "X-Forwarded-For",
  +        apr_table_mergen(r->headers_in, "X-Forwarded-For",
                          r->connection->remote_ip);
   
           /* Add X-Forwarded-Host: so that upstream knows what the
            * original request hostname was.
            */
           if ((buf = apr_table_get(r->headers_in, "Host"))) {
  -            apr_table_setn(r->headers_in, "X-Forwarded-Host", buf);
  +            apr_table_mergen(r->headers_in, "X-Forwarded-Host", buf);
           }
   
           /* Add X-Forwarded-Server: so that upstream knows what the
            * name of this proxy server is (if there are more than one)
            * XXX: This duplicates Via: - do we strictly need it?
            */
  -        apr_table_setn(r->headers_in, "X-Forwarded-Server",
  +        apr_table_mergen(r->headers_in, "X-Forwarded-Server",
                          r->server->server_hostname);
       }
   
  @@ -834,6 +834,10 @@
                                 ap_proxy_location_reverse_map(r, conf, buf));
               }
           }
  +
  +        /* cookies are special: they must not be merged (stupid browsers) */
  +        ap_proxy_table_unmerge(r->pool, r->headers_out, "Set-Cookie");
  +        ap_proxy_table_unmerge(r->pool, r->headers_out, "Set-Cookie2");
   
           r->sent_bodyct = 1;
           /* Is it an HTTP/0.9 response? If so, send the extra data */
  
  
  
  1.81      +31 -1     httpd-2.0/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_util.c,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- proxy_util.c	30 Jan 2002 04:34:11 -0000	1.80
  +++ proxy_util.c	21 Feb 2002 06:06:31 -0000	1.81
  @@ -439,7 +439,8 @@
   	for (end = &value[strlen(value)-1]; end > value && apr_isspace(*end); --end)
   	    *end = '\0';
   
  -        apr_table_add(headers_out, buffer, value);
  +        /* make sure we merge so as not to destroy duplicated headers */
  +        apr_table_merge(headers_out, buffer, value);
   
   	/* the header was too long; at the least we should skip extra data */
   	if (len >= size - 1) { 
  @@ -1070,4 +1071,33 @@
               f = f->next;
           }
       }
  +}
  +
  +/* unmerge an element in the table */
  +void ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key)
  +{
  +    apr_off_t offset = 0;
  +    apr_off_t count = 0;
  +    char *value = NULL;
  +
  +    /* get the value to unmerge */
  +    const char *initial = apr_table_get(t, key);
  +    if (!initial) {
  +        return;
  +    }
  +    value = apr_pstrdup(p, initial);
  +
  +    /* remove the value from the headers */
  +    apr_table_unset(t, key);
  +
  +    /* find each comma */
  +    while (value[count]) {
  +        if (value[count] == ',') {
  +            value[count] = 0;
  +            apr_table_add(t, key, value + offset);
  +            offset = count + 1;
  +        }
  +        count++;
  +    }
  +    apr_table_add(t, key, value + offset);
   }