Index: branches/wmf/1.17wmf1/includes/User.php |
— | — | @@ -3052,7 +3052,9 @@ |
3053 | 3053 | str_replace( |
3054 | 3054 | '$1', |
3055 | 3055 | "Special:$page/$token", |
3056 | | - $wgArticlePath ) ); |
| 3056 | + $wgArticlePath ), |
| 3057 | + PROTO_HTTP |
| 3058 | + ); |
3057 | 3059 | } |
3058 | 3060 | |
3059 | 3061 | /** |
Property changes on: branches/wmf/1.17wmf1/includes/User.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
3060 | 3062 | Merged /trunk/phase3/includes/User.php:r93820-93822 |
Index: branches/wmf/1.17wmf1/includes/parser/CoreParserFunctions.php |
— | — | @@ -647,7 +647,7 @@ |
648 | 648 | // ... and we can |
649 | 649 | if ( $mto && !$mto->isError() ) { |
650 | 650 | // ... change the URL to point to a thumbnail. |
651 | | - $url = wfExpandUrl( $mto->getUrl() ); |
| 651 | + $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE ); |
652 | 652 | } |
653 | 653 | } |
654 | 654 | if ( $option == 'nowiki' ) { |
Index: branches/wmf/1.17wmf1/includes/filerepo/ForeignAPIRepo.php |
— | — | @@ -355,7 +355,7 @@ |
356 | 356 | public static function httpGet( $url, $timeout = 'default', $options = array() ) { |
357 | 357 | $options['timeout'] = $timeout; |
358 | 358 | /* Http::get */ |
359 | | - $url = wfExpandUrl( $url ); |
| 359 | + $url = wfExpandUrl( $url, PROTO_HTTP ); |
360 | 360 | wfDebug( "ForeignAPIRepo: HTTP GET: $url\n" ); |
361 | 361 | $options['method'] = "GET"; |
362 | 362 | |
Index: branches/wmf/1.17wmf1/includes/api/ApiMain.php |
— | — | @@ -381,15 +381,19 @@ |
382 | 382 | } |
383 | 383 | |
384 | 384 | protected function sendCacheHeaders() { |
| 385 | + global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI; |
385 | 386 | if ( $this->mCacheMode == 'private' ) { |
386 | 387 | header( 'Cache-Control: private' ); |
387 | 388 | return; |
388 | 389 | } |
389 | 390 | |
390 | 391 | if ( $this->mCacheMode == 'anon-public-user-private' ) { |
391 | | - global $wgUseXVO, $wgOut; |
392 | | - header( 'Vary: Accept-Encoding, Cookie' ); |
| 392 | + $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : ''; |
| 393 | + header( 'Vary: Accept-Encoding, Cookie' . $xfp ); |
393 | 394 | if ( $wgUseXVO ) { |
| 395 | + if ( $wgVaryOnXFPForAPI ) { |
| 396 | + $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); |
| 397 | + } |
394 | 398 | header( $wgOut->getXVO() ); |
395 | 399 | if ( $wgOut->haveCacheVaryCookies() ) { |
396 | 400 | // Logged in, mark this request private |
— | — | @@ -404,6 +408,15 @@ |
405 | 409 | return; |
406 | 410 | } // else no XVO and anonymous, send public headers below |
407 | 411 | } |
| 412 | + |
| 413 | + // Send public headers |
| 414 | + if ( $wgVaryOnXFPForAPI ) { |
| 415 | + header( 'Vary: Accept-Encoding, X-Forwarded-Proto' ); |
| 416 | + if ( $wgUseXVO ) { |
| 417 | + // Bleeeeegh. Our header setting system sucks |
| 418 | + header( 'X-Vary-Options: Accept-Encoding;list-contains=gzip, X-Forwarded-Proto' ); |
| 419 | + } |
| 420 | + } |
408 | 421 | |
409 | 422 | // If nobody called setCacheMaxAge(), use the (s)maxage parameters |
410 | 423 | if ( !isset( $this->mCacheControl['s-maxage'] ) ) { |
Index: branches/wmf/1.17wmf1/includes/WebRequest.php |
— | — | @@ -552,6 +552,8 @@ |
553 | 553 | |
554 | 554 | /** |
555 | 555 | * Return the request URI with the canonical service and hostname. |
| 556 | + * |
| 557 | + * NOTE: This will output a protocol-relative URL if $wgServer is protocol-relative |
556 | 558 | * |
557 | 559 | * @return String |
558 | 560 | */ |
Property changes on: branches/wmf/1.17wmf1/includes/WebRequest.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
559 | 561 | Merged /trunk/phase3/includes/WebRequest.php:r93820-93822 |
Index: branches/wmf/1.17wmf1/includes/resourceloader/ResourceLoaderFileModule.php |
— | — | @@ -202,8 +202,9 @@ |
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
206 | | - // Make sure the remote base path is a complete valid url |
207 | | - $this->remoteBasePath = wfExpandUrl( $this->remoteBasePath ); |
| 206 | + // Make sure the remote base path is a complete valid URL, |
| 207 | + // but possibly protocol-relative to avoid cache pollution |
| 208 | + $this->remoteBasePath = wfExpandUrl( $this->remoteBasePath, PROTO_RELATIVE ); |
208 | 209 | } |
209 | 210 | |
210 | 211 | /** |
Index: branches/wmf/1.17wmf1/includes/libs/CSSMin.php |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | // to absolute URLs but otherwise left alone |
133 | 133 | if ( $match['file'][0] !== '' && $match['file'][0][0] === '/' ) { |
134 | 134 | // Replace the file path with an expanded URL |
135 | | - $source = substr_replace( $source, wfExpandUrl( $match['file'][0] ), |
| 135 | + $source = substr_replace( $source, wfExpandUrl( $match['file'][0], PROTO_RELATIVE ), |
136 | 136 | $match['file'][1], strlen( $match['file'][0] ) |
137 | 137 | ); |
138 | 138 | // Move the offset to the end of the match, leaving it alone |
Index: branches/wmf/1.17wmf1/includes/DefaultSettings.php |
— | — | @@ -1739,6 +1739,13 @@ |
1740 | 1740 | /** Send X-Vary-Options header for better caching (requires patched Squid) */ |
1741 | 1741 | $wgUseXVO = false; |
1742 | 1742 | |
| 1743 | +/** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API |
| 1744 | + * requests. Use this if you have an SSL termination setup and want to split |
| 1745 | + * the cache between HTTP and HTTPS for API requests. This does not affect |
| 1746 | + * 'regular' requests. |
| 1747 | + */ |
| 1748 | +$wgVaryOnXFPForAPI = false; |
| 1749 | + |
1743 | 1750 | /** |
1744 | 1751 | * Internal server name as known to Squid, if different. Example: |
1745 | 1752 | * <code> |
Property changes on: branches/wmf/1.17wmf1/includes/DefaultSettings.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1746 | 1753 | Merged /trunk/phase3/includes/DefaultSettings.php:r93820-93822 |
Index: branches/wmf/1.17wmf1/includes/HttpFunctions.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * Perform an HTTP request |
16 | 16 | * |
17 | 17 | * @param $method String: HTTP method. Usually GET/POST |
18 | | - * @param $url String: full URL to act on |
| 18 | + * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL |
19 | 19 | * @param $options Array: options to pass to MWHttpRequest object. |
20 | 20 | * Possible keys for the array: |
21 | 21 | * - timeout Timeout length in seconds |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @return Mixed: (bool)false on failure or a string on success |
34 | 34 | */ |
35 | 35 | public static function request( $method, $url, $options = array() ) { |
36 | | - $url = wfExpandUrl( $url ); |
| 36 | + $url = wfExpandUrl( $url, PROTO_HTTP ); |
37 | 37 | wfDebug( "HTTP: $method: $url\n" ); |
38 | 38 | $options['method'] = strtoupper( $method ); |
39 | 39 | |