Make $wgVaryOnXFPForAPI apply to RSS/Atom feeds too, because they too use PROT_CURREN...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 19 Aug 2011 14:41:35 +0000 (14:41 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 19 Aug 2011 14:41:35 +0000 (14:41 +0000)
includes/DefaultSettings.php
includes/Feed.php

index 4ca6b43..9bf4cf7 100644 (file)
@@ -1753,9 +1753,9 @@ $wgUseESI = false;
 $wgUseXVO = false;
 
 /** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API
- * requests. Use this if you have an SSL termination setup and want to split
- * the cache between HTTP and HTTPS for API requests. This does not affect
- * 'regular' requests.
+ * 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.
  */
 $wgVaryOnXFPForAPI = false;
 
index 528b5f5..6f49931 100644 (file)
@@ -239,12 +239,15 @@ class ChannelFeed extends FeedItem {
         * but can also be called separately.
         */
        public function httpHeaders() {
-               global $wgOut;
+               global $wgOut, $wgVaryOnXFPForAPI;
 
                # We take over from $wgOut, excepting its cache header info
                $wgOut->disable();
                $mimetype = $this->contentType();
                header( "Content-type: $mimetype; charset=UTF-8" );
+               if ( $wgVaryOnXFPForAPI ) {
+                       $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
+               }
                $wgOut->sendCacheControl();
 
        }
@@ -273,7 +276,7 @@ class ChannelFeed extends FeedItem {
                $this->httpHeaders();
                echo '<?xml version="1.0"?>' . "\n";
                echo '<?xml-stylesheet type="text/css" href="' .
-                       htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) .
+                       htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion", PROTO_CURRENT ) ) .
                        '"?' . ">\n";
        }
 }