From: Catrope Date: Fri, 1 Jun 2012 10:23:53 +0000 (-0700) Subject: Make OutputPage's mechanism for gathering Vary headers reusable X-Git-Tag: 1.31.0-rc.0~23159^2 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=9867c1d1a22d458032e19ec73bb20831576b0123;p=lhc%2Fweb%2Fwiklou.git Make OutputPage's mechanism for gathering Vary headers reusable Maybe WebResponse would be a better place for this, but this'll work for now. * Add getVaryHeader() to get the serialized version of $mVaryHeader. * Remove 'Cookie' from the initializer, and add it explicitly later ** This allows reuse by code that doesn't want 'Cookie' in there Change-Id: Ifa8f74a21f832154b05e54ced95b9f9eb6052fcd --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 35b2f38580..4a451757a7 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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