* @return void
*/
function wfStreamThumb( array $params ) {
+ global $wgVaryOnXFP;
wfProfileIn( __METHOD__ );
$headers = array(); // HTTP headers to send
}
// Check permissions if there are read restrictions
+ $varyHeader = array();
if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
if ( !$img->getTitle() || !$img->getTitle()->userCan( 'read' ) ) {
wfThumbError( 403, 'Access denied. You do not have permission to access ' .
return;
}
$headers[] = 'Cache-Control: private';
- $headers[] = 'Vary: Cookie';
+ $varyHeader[] = 'Cookie';
}
// Check the source file storage path
$response->header( 'Location: ' . wfExpandUrl( $img->getThumbUrl( $thumbName ), PROTO_CURRENT ) );
$response->header( 'Expires: ' .
gmdate( 'D, d M Y H:i:s', time() + 7*86400 ) . ' GMT' );
+ if ( $wgVaryOnXFP ) {
+ $varyHeader[] = 'X-Forwarded-Proto';
+ }
+ $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
+ wfProfileOut( __METHOD__ );
+ return;
} else {
wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
wfProfileOut( __METHOD__ );
}
$thumbPath = $img->getThumbPath( $thumbName );
if ( $img->getRepo()->fileExists( $thumbPath ) ) {
+ $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
$img->getRepo()->streamFile( $thumbPath, $headers );
wfProfileOut( __METHOD__ );
return;
wfProfileOut( __METHOD__ );
return;
}
+ $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
// Thumbnail isn't already there, so create the new thumbnail...
try {