hello, Christian

I found a bug with how Apache::ProxyRewite handles cookies.

Our proxy server was trying to display a remote application that heavily uses cookies 
butthe application was failing miserably.

I compared the headers of what the proxy server was sending to the client vs. what the 
remote server was displaying. the proxy server was only sending one (the last one) of 
4 Set-Cookie headers.

The problems lies in the way that all headers are set:
$r->headers_out->{$header} = $value;

I patched the server by changing sum code in: sub respond { }
to allow for multiple cookie headers. 

Here is what I did:
  # feed reponse back into our request_record
  $response->scan(sub {
                    my ($header, $value) = @_;
                    $r->log->debug("respond: OUT $header: $value");
                    if ($header =~ /^Set-Cookie/i) {
                      $value =~ /path=([^;]+)/i;
                      my $cookie_path = $1;
                      &rewrite_url($r, $remote_site, \$cookie_path, $mapref);
                      $value =~ s/(path=)([^;]+)/$1$cookie_path/i;

                      # Multiple Cookie Patch added by amen
                      # 04/03/2002
                      $r->headers_out->add( 'Set-Cookie' => $value );
                      $r->log->debug("respond: OUT-MOD $header: $value");
                    } else {
                      $r->headers_out->{$header} = $value;
                    }
                  });

Makes sense :)

thanx for writing this,
-amen

BTW> we are using version 0.15

Reply via email to