vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r18350: LJSUP-7541: Reduce Set-Cookie usage

Committer: vsukhanov
LJSUP-7541: Reduce Set-Cookie usage
U   trunk/cgi-bin/LJ/Request/Apache2.pm
U   trunk/cgi-bin/LJ/Request.pm
Modified: trunk/cgi-bin/LJ/Request/Apache2.pm
===================================================================
--- trunk/cgi-bin/LJ/Request/Apache2.pm	2011-02-18 04:02:52 UTC (rev 18349)
+++ trunk/cgi-bin/LJ/Request/Apache2.pm	2011-02-18 05:17:04 UTC (rev 18350)
@@ -448,8 +448,10 @@
     my $value  = shift;
 
     my $r = $class->r();
+    ## The difference between headers_out and err_headers_out, is that 
+    ## the latter are printed even on error, and persist across internal redirects 
+    ## (so the headers printed for ErrorDocument handlers will have them).
     $r->err_headers_out->add($header, $value);
-    $r->headers_out->add($header, $value);
 
     return 1;
 }
@@ -461,8 +463,10 @@
     my $value  = shift;
 
     my $r = $class->r();
+    ## The difference between headers_out and err_headers_out, is that 
+    ## the latter are printed even on error, and persist across internal redirects 
+    ## (so the headers printed for ErrorDocument handlers will have them).
     $r->err_headers_out->set($header, $value);
-    $r->headers_out->set($header, $value);
 
     return 1;
 }

Modified: trunk/cgi-bin/LJ/Request.pm
===================================================================
--- trunk/cgi-bin/LJ/Request.pm	2011-02-18 04:02:52 UTC (rev 18349)
+++ trunk/cgi-bin/LJ/Request.pm	2011-02-18 05:17:04 UTC (rev 18350)
@@ -235,6 +235,9 @@
     $header .= "; domain=$opts{'domain'}" if $opts{'domain'};
     $header .= "; HttpOnly" if $opts{'http_only'};
 
+    ## Only one cookie with same name
+    @cookie_set = grep { $_->{name} ne $key } @cookie_set;
+
     push @cookie_set, {
         'name' => $key,
         'value' => $value,
@@ -247,6 +250,7 @@
     };
 
     push @{$cookie{$key}}, $value;
+
 }
 
 sub delete_cookie {

Tags: livejournal, pm, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments