From 403f87be35e93a1cd205c619310b08f682dfc838 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 3 Oct 2011 13:15:28 +0000 Subject: [PATCH] Rename $wgVaryOnXFPForAPI (introduced in r93818) to $wgVaryOnXFP and extend it to also apply to HTTP redirects. The previous name was overly specific for what has become a more generic setting, and we can still change it now that it's not in any release yet. --- includes/DefaultSettings.php | 8 +++++--- includes/Feed.php | 4 ++-- includes/OutputPage.php | 5 ++++- includes/api/ApiMain.php | 8 ++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d46c10de7c..99a3abb8af 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1754,10 +1754,12 @@ $wgUseXVO = false; /** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API * requests and RSS/Atom feeds. Use this if you have an SSL termination setup - * and need to split the cache between HTTP and HTTPS for API and feed requests - * in order to prevent cache pollution. This does not affect 'normal' requests. + * and need to split the cache between HTTP and HTTPS for API requests, + * feed requests and HTTP redirect responses in order to prevent cache + * pollution. This does not affect 'normal' requests to index.php other than + * HTTP redirects. */ -$wgVaryOnXFPForAPI = false; +$wgVaryOnXFP = false; /** * Internal server name as known to Squid, if different. Example: diff --git a/includes/Feed.php b/includes/Feed.php index 3e0c913f48..ef33c78ffb 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -239,13 +239,13 @@ class ChannelFeed extends FeedItem { * but can also be called separately. */ public function httpHeaders() { - global $wgOut, $wgVaryOnXFPForAPI; + global $wgOut, $wgVaryOnXFP; # We take over from $wgOut, excepting its cache header info $wgOut->disable(); $mimetype = $this->contentType(); header( "Content-type: $mimetype; charset=UTF-8" ); - if ( $wgVaryOnXFPForAPI ) { + if ( $wgVaryOnXFP ) { $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); } $wgOut->sendCacheControl(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 9585dfbece..fa598a42c3 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1806,7 +1806,7 @@ class OutputPage extends ContextSource { * the object, let's actually output it: */ public function output() { - global $wgLanguageCode, $wgDebugRedirects, $wgMimeType; + global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP; if( $this->mDoNothing ) { return; @@ -1826,6 +1826,9 @@ class OutputPage extends ContextSource { } $this->mLastModified = wfTimestamp( TS_RFC2822 ); } + if ( $wgVaryOnXFP ) { + $this->addVaryHeader( 'X-Forwarded-Proto' ); + } $this->sendCacheControl(); $response->header( "Content-Type: text/html; charset=utf-8" ); diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index a88a0a5399..a3e2fd7716 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -399,7 +399,7 @@ class ApiMain extends ApiBase { } protected function sendCacheHeaders() { - global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI; + global $wgUseXVO, $wgOut, $wgVaryOnXFP; $response = $this->getRequest()->response(); if ( $this->mCacheMode == 'private' ) { @@ -408,10 +408,10 @@ class ApiMain extends ApiBase { } if ( $this->mCacheMode == 'anon-public-user-private' ) { - $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : ''; + $xfp = $wgVaryOnXFP ? ', X-Forwarded-Proto' : ''; $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp ); if ( $wgUseXVO ) { - if ( $wgVaryOnXFPForAPI ) { + if ( $wgVaryOnXFP ) { $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); } $response->header( $wgOut->getXVO() ); @@ -430,7 +430,7 @@ class ApiMain extends ApiBase { } // Send public headers - if ( $wgVaryOnXFPForAPI ) { + if ( $wgVaryOnXFP ) { $response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' ); if ( $wgUseXVO ) { // Bleeeeegh. Our header setting system sucks -- 2.20.1