projects
/
mkws-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ea5fa54
)
Add code to copy cookies back through from client.
author
Mike Taylor
<mike@indexdata.com>
Wed, 26 Jun 2013 12:36:33 +0000
(14:36 +0200)
committer
Mike Taylor
<mike@indexdata.com>
Wed, 26 Jun 2013 12:36:33 +0000
(14:36 +0200)
etc/mod_perl/MyApache2/CopyCookie.pm
patch
|
blob
|
history
diff --git
a/etc/mod_perl/MyApache2/CopyCookie.pm
b/etc/mod_perl/MyApache2/CopyCookie.pm
index
8961d74
..
3dbade1
100644
(file)
--- a/
etc/mod_perl/MyApache2/CopyCookie.pm
+++ b/
etc/mod_perl/MyApache2/CopyCookie.pm
@@
-12,17
+12,25
@@
sub handler {
my $f = shift;
warn "in MyApache2::CopyCookie (f=$f)";
my $f = shift;
warn "in MyApache2::CopyCookie (f=$f)";
+ # If the server generated a new cookie, make it available in a
+ # header other than the magic "Cookie" that clients can't read.
my $ho = $f->r->headers_out;
my $cookie = $ho->get('Set-Cookie');
my $ho = $f->r->headers_out;
my $cookie = $ho->get('Set-Cookie');
- warn "MyApache2::CopyCookie headers_out='$ho', cookie='$cookie'";
$ho->set('X-Set-Cookie', $cookie);
$ho->set('X-Set-Cookie', $cookie);
- my $extra = $ho->get('X-Set-Cookie');
- warn "MyApache2::CopyCookie extra cookie='$extra'";
+
+ # If the client sent an existing cookie as X-Cookie, but didn't
+ # set Cookie, copy the former to the latter.
+ my $hi = $f->r->headers_in;
+ $cookie = $hi->get('Cookie');
+ if (!defined $cookie || $cookie eq "") {
+ $cookie = $hi->get('X-Cookie');
+ warn "copying X-Cookie '$cookie' to Cookie";
+ $hi->set('Cookie', $cookie);
+ }
while ($f->read(my $buffer, BUFF_LEN)) {
$f->print($buffer);
}
while ($f->read(my $buffer, BUFF_LEN)) {
$f->print($buffer);
}
- warn "MyApache2::CopyCookie copied data";
return Apache2::Const::OK;
}
return Apache2::Const::OK;
}