You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2007/05/07 13:36:25 UTC

svn commit: r535856 - in /httpd/httpd/branches/2.0.x: CHANGES STATUS modules/proxy/proxy_http.c

Author: jim
Date: Mon May  7 04:36:24 2007
New Revision: 535856

URL: http://svn.apache.org/viewvc?view=rev&rev=535856
Log:
Approved backport. Overlay cookies as we do with 2.2 and later.

Modified:
    httpd/httpd/branches/2.0.x/CHANGES
    httpd/httpd/branches/2.0.x/STATUS
    httpd/httpd/branches/2.0.x/modules/proxy/proxy_http.c

Modified: httpd/httpd/branches/2.0.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/CHANGES?view=diff&rev=535856&r1=535855&r2=535856
==============================================================================
--- httpd/httpd/branches/2.0.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.0.x/CHANGES [utf-8] Mon May  7 04:36:24 2007
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.0.60
 
+  *) proxy_http.c: Overlay existing cookies with proxied ones, ala
+     httpd-2.2. [Jim Jagielski]
+
   *) mod_proxy: ProxyTimeout (and others) ignored due to not merging
      the *_set params. PR 11540. [Jim Jagielski]
 

Modified: httpd/httpd/branches/2.0.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/STATUS?view=diff&rev=535856&r1=535855&r2=535856
==============================================================================
--- httpd/httpd/branches/2.0.x/STATUS (original)
+++ httpd/httpd/branches/2.0.x/STATUS Mon May  7 04:36:24 2007
@@ -136,11 +136,6 @@
       Trunk: http://svn.apache.org/viewvc?view=rev&revision=442758
       +1: niq, wrowe, rpluem
 
-    * proxy_http.c: Overlay existing cookies with proxied
-      ones, ala httpd-2.2 and trunk.
-      Patch: http://people.apache.org/~jim/patches/cookie-overlay.patch
-      +1: jim, wrowe, rpluem
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ please place SVN revisions from trunk here, so it is easy to
     identify exactly what the proposed changes are!  Add all new

Modified: httpd/httpd/branches/2.0.x/modules/proxy/proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/modules/proxy/proxy_http.c?view=diff&rev=535856&r1=535855&r2=535856
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/proxy/proxy_http.c (original)
+++ httpd/httpd/branches/2.0.x/modules/proxy/proxy_http.c Mon May  7 04:36:24 2007
@@ -1282,6 +1282,12 @@
     return APR_SUCCESS;
 }
 
+static int addit_dammit(void *v, const char *key, const char *val)
+{
+    apr_table_addn(v, key, val);
+    return 1;
+}
+
 static
 apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
                                             proxy_http_conn_t *p_conn,
@@ -1296,6 +1302,7 @@
     char keepchar;
     request_rec *rp;
     apr_bucket *e;
+    apr_table_t *save_table;
     int len, backasswards;
     int received_continue = 1; /* flag to indicate if we should
                                 * loop over response parsing logic
@@ -1372,6 +1379,11 @@
             /* N.B. for HTTP/1.0 clients, we have to fold line-wrapped headers*/
             /* Also, take care with headers with multiple occurences. */
 
+            /* First, tuck away all already existing cookies */
+            save_table = apr_table_make(r->pool, 2);
+            apr_table_do(addit_dammit, save_table, r->headers_out,
+                         "Set-Cookie", NULL);
+
             r->headers_out = ap_proxy_read_headers(r, rp, buffer,
                                                    sizeof(buffer), origin);
             if (r->headers_out == NULL) {
@@ -1389,6 +1401,18 @@
                 r->status = HTTP_BAD_GATEWAY;
                 r->status_line = "bad gateway";
                 return r->status;
+            }
+
+            /* Now, add in the just read cookies */
+            apr_table_do(addit_dammit, save_table, r->headers_out,
+                         "Set-Cookie", NULL);
+
+            /* and now load 'em all in */
+            if (!apr_is_empty_table(save_table)) {
+                apr_table_unset(r->headers_out, "Set-Cookie");
+                r->headers_out = apr_table_overlay(r->pool,
+                                                   r->headers_out,
+                                                   save_table);
             }
 
             /* can't have both Content-Length and Transfer-Encoding */