Pedro Melo Cunha wrote:
> Hi,
> 
> a bit of history: I read on the documentation the new mod_proxy feature
> called ProxyIOBufferSize which allows for even better handling of lasrge
> mod_perl httpd's. This babby, and another little patch that also made it
> (closing the backend connection as soon as possible) allows for me to
> have a split of 100 modproxy process for only 10 backend mod_perl
> process... neat! :) (BTW, using this and mod_gzip, and you can save a
> bundle instead of buying those nice redline boxes :)
> 
> the problem is that it's only available on 1.3.24 (at the time, 2 or 3
> days ago, it wasnt available yet), so I used the CVS version.
> 
> Looking at the change log, they mention a bug that multiple set-cookie's
> will fail (only the last one will be sent to the client, the proxy will
> "eat" the others). And it was true... The problem is that 1.3.24 final
> also has that bug: only the last set-cookie will reach your browser.
> 
> This was a show-stopper for my application. So I sat down, read the
> proxy code, and made a patch to solve the bug. I then sent the patch to
> the apache bug database (i really hate gnats ;), but they drop it (as a
> duplicate). I admit i could not attach my patch to the existing bug
> report on this subject (I said I hated gnat's :). So my patch did not
> made it the 1.3.24...

Pedro, please send it to dev @ httpd.apache.org.

> Anyway, I attached here. Maybe someone here can push it into apache for
> the next release, and in the meantime you can use it, if you want.
> 
> I also attach a cgi that set's two cookies, to demonstrate the problem.
> 
> Best regards,
> 
> PS: mod_perl totally rocks... serving well over 70.000.000 pageviews
>     with mason...
> 
> 
> ------------------------------------------------------------------------
> 
> Index: proxy_http.c
> ===================================================================
> RCS file: /home/cvspublic/apache-1.3/src/modules/proxy/proxy_http.c,v
> retrieving revision 1.88
> diff -u -r1.88 proxy_http.c
> --- proxy_http.c      21 Mar 2002 11:38:03 -0000      1.88
> +++ proxy_http.c      22 Mar 2002 01:21:39 -0000
> @@ -136,6 +136,20 @@
>      return url;
>  }
>  
> +
> +/* copies header key/value into table p if it's a cookie header.
> + * this is a callback function for a ap_table_do below.
> + */
> +int ap_proxy_copy_cookie_headers(void *p, const char *key, const char *value)
> +{
> +    table *d = (table *)p;
> +
> +    if (!strcasecmp(key, "Set-Cookie") || !strcasecmp(key, "Set-Cookie2"))
> +      ap_table_add(d, key, value);
> +
> +    return 1;
> +}
> +
>  /*
>   * This handles http:// URLs, and other URLs using a remote proxy over http
>   * If proxyhost is NULL, then contact the server directly, otherwise
> @@ -529,8 +543,20 @@
>          ap_proxy_write_headers(c, ap_pstrcat(p, "HTTP/1.1 ", r->status_line, NULL), 
>resp_hdrs);
>      }
>  
> -    /* Setup the headers for our client from upstreams response-headers */
> +    /* Setup the headers for our client from upstreams response-headers.
> +     * We use resp_hdrs to keep all the Set-Cookie and Set-Cookie2 headers,
> +     * and then call ap_overlap_table, because it keep's only the last one.
> +     * The we copy all the cookies back.
> +              */
> +    ap_table_do(ap_proxy_copy_cookie_headers, resp_hdrs, r->headers_out, NULL);
> +
>      ap_overlap_tables(r->headers_out, resp_hdrs, AP_OVERLAP_TABLES_SET);
> +
> +    ap_table_unset(r->headers_out, "Set-Cookie");
> +    ap_table_unset(r->headers_out, "Set-Cookie2");
> +
> +    ap_table_do(ap_proxy_copy_cookie_headers, r->headers_out, resp_hdrs, NULL);
> +
>      /* Add X-Cache header - be careful not to obliterate any upstream headers */
>      ap_table_mergen(r->headers_out, "X-Cache",
>                    ap_pstrcat(r->pool, "MISS from ",
> 
> 
> ------------------------------------------------------------------------
> 
> #!/usr/local/bin/perl -w
> 
> use CGI qw( :standard );
> use CGI::Cookie;
> 
> my $c1 = new CGI::Cookie(-name=>'ID',-value=>123456);
> my $c2 = new CGI::Cookie(-name=>'preferences',
>                          -value=>{ font => Helvetica, size => 12 });
> 
> print header(-cookie=>[$c1,$c2]);
> 
> print "Done";



-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Reply via email to