Merge "Make OutputPage's mechanism for gathering Vary headers reusable"
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Jul 2012 18:01:31 +0000 (18:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Jul 2012 18:01:31 +0000 (18:01 +0000)
includes/OutputPage.php

index d0545da..c00cfbe 100644 (file)
@@ -237,7 +237,6 @@ class OutputPage extends ContextSource {
        private $mFollowPolicy = 'follow';
        private $mVaryHeader = array(
                'Accept-Encoding' => array( 'list-contains=gzip' ),
-               'Cookie' => null
        );
 
        /**
@@ -1722,6 +1721,16 @@ class OutputPage extends ContextSource {
                $this->mVaryHeader[$header] = array_unique( (array)$this->mVaryHeader[$header] );
        }
 
+       /**
+        * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader,
+        * such as Accept-Encoding or Cookie
+        * 
+        * @return String
+        */
+       public function getVaryHeader() {
+               return 'Vary: ' . join( ', ', array_keys( $this->mVaryHeader ) );
+       }
+
        /**
         * Get a complete X-Vary-Options header
         *
@@ -1834,11 +1843,12 @@ class OutputPage extends ContextSource {
                        $response->header( "ETag: $this->mETag" );
                }
 
+               $this->addVaryHeader( 'Cookie' );
                $this->addAcceptLanguage();
 
                # don't serve compressed data to clients who can't handle it
                # maintain different caches for logged-in users and non-logged in ones
-               $response->header( 'Vary: ' . join( ', ', array_keys( $this->mVaryHeader ) ) );
+               $response->header( $this->getVaryHeader() );
 
                if ( $wgUseXVO ) {
                        # Add an X-Vary-Options header for Squid with Wikimedia patches