Copy data
[mkws-moved-to-github.git] / etc / mod_perl / MyApache2 / CopyCookie.pm
index 2cdf24f..8961d74 100644 (file)
@@ -6,11 +6,24 @@ use APR::Table ();
 
 use Apache2::Const -compile => qw(OK);
 
+use constant BUFF_LEN => 1024;
+
 sub handler {
     my $f = shift;
+    warn "in MyApache2::CopyCookie (f=$f)";
+
+    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);
+    my $extra = $ho->get('X-Set-Cookie');
+    warn "MyApache2::CopyCookie extra cookie='$extra'";
+
+    while ($f->read(my $buffer, BUFF_LEN)) {
+       $f->print($buffer);
+    }
+    warn "MyApache2::CopyCookie copied data";
 
-    my $cookie = $f->r->headers_out->get('Set-Cookie');
-    $f->r->headers_out->set('X-Set-Cookie', $cookie);
     return Apache2::Const::OK;
 }