From: Catrope Date: Fri, 1 Jun 2012 11:11:32 +0000 (-0700) Subject: In ApiMain, gather Vary headers in OutputPage X-Git-Tag: 1.31.0-rc.0~23128 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=7da3bb81f70bf6bfefed770c674af4fbe4b093a8;p=lhc%2Fweb%2Fwiklou.git In ApiMain, gather Vary headers in OutputPage Using OutputPage for this rather than something like WebResponse probably isn't optimal, but it's a lot nicer than the mess we had before. Change-Id: I9dce06d3eb69dd7952eafc6c94ead2ad5ad88792 --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 30e9fb68be..3a9698da12 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -405,6 +405,11 @@ class ApiMain extends ApiBase { protected function sendCacheHeaders() { global $wgUseXVO, $wgVaryOnXFP; $response = $this->getRequest()->response(); + $out = $this->getOutput(); + + if ( $wgVaryOnXFP ) { + $out->addVaryHeader( 'X-Forwarded-Proto' ); + } if ( $this->mCacheMode == 'private' ) { $response->header( 'Cache-Control: private' ); @@ -412,13 +417,9 @@ class ApiMain extends ApiBase { } if ( $this->mCacheMode == 'anon-public-user-private' ) { - $xfp = $wgVaryOnXFP ? ', X-Forwarded-Proto' : ''; - $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp ); + $out->addVaryHeader( 'Cookie' ); + $response->header( $out->getVaryHeader() ); if ( $wgUseXVO ) { - $out = $this->getOutput(); - if ( $wgVaryOnXFP ) { - $out->addVaryHeader( 'X-Forwarded-Proto' ); - } $response->header( $out->getXVO() ); if ( $out->haveCacheVaryCookies() ) { // Logged in, mark this request private @@ -435,12 +436,9 @@ class ApiMain extends ApiBase { } // Send public headers - if ( $wgVaryOnXFP ) { - $response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' ); - if ( $wgUseXVO ) { - // Bleeeeegh. Our header setting system sucks - $response->header( 'X-Vary-Options: Accept-Encoding;list-contains=gzip, X-Forwarded-Proto' ); - } + $response->header( $out->getVaryHeader() ); + if ( $wgUseXVO ) { + $response->header( $out->getXVO() ); } // If nobody called setCacheMaxAge(), use the (s)maxage parameters