r98755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98754‎ | r98755 | r98756 >
Date:13:15, 3 October 2011
Author:catrope
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Feed.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Feed.php
@@ -239,13 +239,13 @@
240240 * but can also be called separately.
241241 */
242242 public function httpHeaders() {
243 - global $wgOut, $wgVaryOnXFPForAPI;
 243+ global $wgOut, $wgVaryOnXFP;
244244
245245 # We take over from $wgOut, excepting its cache header info
246246 $wgOut->disable();
247247 $mimetype = $this->contentType();
248248 header( "Content-type: $mimetype; charset=UTF-8" );
249 - if ( $wgVaryOnXFPForAPI ) {
 249+ if ( $wgVaryOnXFP ) {
250250 $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
251251 }
252252 $wgOut->sendCacheControl();
Index: trunk/phase3/includes/OutputPage.php
@@ -1806,7 +1806,7 @@
18071807 * the object, let's actually output it:
18081808 */
18091809 public function output() {
1810 - global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
 1810+ global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP;
18111811
18121812 if( $this->mDoNothing ) {
18131813 return;
@@ -1826,6 +1826,9 @@
18271827 }
18281828 $this->mLastModified = wfTimestamp( TS_RFC2822 );
18291829 }
 1830+ if ( $wgVaryOnXFP ) {
 1831+ $this->addVaryHeader( 'X-Forwarded-Proto' );
 1832+ }
18301833 $this->sendCacheControl();
18311834
18321835 $response->header( "Content-Type: text/html; charset=utf-8" );
Index: trunk/phase3/includes/api/ApiMain.php
@@ -399,7 +399,7 @@
400400 }
401401
402402 protected function sendCacheHeaders() {
403 - global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI;
 403+ global $wgUseXVO, $wgOut, $wgVaryOnXFP;
404404 $response = $this->getRequest()->response();
405405
406406 if ( $this->mCacheMode == 'private' ) {
@@ -408,10 +408,10 @@
409409 }
410410
411411 if ( $this->mCacheMode == 'anon-public-user-private' ) {
412 - $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : '';
 412+ $xfp = $wgVaryOnXFP ? ', X-Forwarded-Proto' : '';
413413 $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp );
414414 if ( $wgUseXVO ) {
415 - if ( $wgVaryOnXFPForAPI ) {
 415+ if ( $wgVaryOnXFP ) {
416416 $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
417417 }
418418 $response->header( $wgOut->getXVO() );
@@ -430,7 +430,7 @@
431431 }
432432
433433 // Send public headers
434 - if ( $wgVaryOnXFPForAPI ) {
 434+ if ( $wgVaryOnXFP ) {
435435 $response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' );
436436 if ( $wgUseXVO ) {
437437 // Bleeeeegh. Our header setting system sucks
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1754,10 +1754,12 @@
17551755
17561756 /** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API
17571757 * requests and RSS/Atom feeds. Use this if you have an SSL termination setup
1758 - * and need to split the cache between HTTP and HTTPS for API and feed requests
1759 - * in order to prevent cache pollution. This does not affect 'normal' requests.
 1758+ * and need to split the cache between HTTP and HTTPS for API requests,
 1759+ * feed requests and HTTP redirect responses in order to prevent cache
 1760+ * pollution. This does not affect 'normal' requests to index.php other than
 1761+ * HTTP redirects.
17601762 */
1761 -$wgVaryOnXFPForAPI = false;
 1763+$wgVaryOnXFP = false;
17621764
17631765 /**
17641766 * Internal server name as known to Squid, if different. Example:

Follow-up revisions

RevisionCommit summaryAuthorDate
r987571.17wmf1: MFT r98755catrope13:20, 3 October 2011
r987581.18wmf1: MFT r98755catrope13:20, 3 October 2011
r100841REL1_18 MFT r98703, r98755, r98880reedy18:52, 26 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93818Introduce $wgVaryOnXFPToAPI which sends Vary: X-Forwarded-Proto (and the appr...catrope12:00, 3 August 2011

Status & tagging log