Rename $wgVaryOnXFPForAPI (introduced in r93818) to $wgVaryOnXFP and extend it to...
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 3 Oct 2011 13:15:28 +0000 (13:15 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 3 Oct 2011 13:15:28 +0000 (13:15 +0000)
includes/DefaultSettings.php
includes/Feed.php
includes/OutputPage.php
includes/api/ApiMain.php

index d46c10d..99a3abb 100644 (file)
@@ -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:
index 3e0c913..ef33c78 100644 (file)
@@ -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();
index 9585dfb..fa598a4 100644 (file)
@@ -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" );
index a88a0a5..a3e2fd7 100644 (file)
@@ -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