aboutsummaryrefslogtreecommitdiffstats
path: root/img_auth.php
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2014-04-20 01:40:06 -0700
committerAaron Schulz <aschulz@wikimedia.org>2016-06-04 05:43:43 -0700
commitd42a05475a1fec48de72fdee961de66c1af2279a (patch)
tree27079d0a19d57dc0dcfc3b6fb6b3263924679d2b /img_auth.php
parent633c0da23af1cdb16f8edb6252f1c1138422162c (diff)
downloadmediawikicore-d42a05475a1fec48de72fdee961de66c1af2279a.tar.gz
mediawikicore-d42a05475a1fec48de72fdee961de66c1af2279a.zip
Added Range support to FileBackend::streamFile()
* Added HTTP options headers parameter to streamFile(). * Refactored doStreamFile() to either call StreamFile::stream() or delagate that to the subclass. SwiftFileBackend now relays the full Swift response rather than manually making the headers. This also makes Range headers easy to support. * Made use of this in img_auth.php for performance on private wikis. * Elimate stat call in streamFile() for Swift if "headers" is empty. * Refactored StreamFile a bit to inject request headers instead of using the $_SERVER global. A header options parameter is used instead, which also supports Range. * Removed now unused prepareForStream(). * Cleaned up streamFile() unit tests. Change-Id: I2ccbcbca6caabb8cf65bd6b3084cede2e6ea628a
Diffstat (limited to 'img_auth.php')
-rw-r--r--img_auth.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/img_auth.php b/img_auth.php
index d63618817a19..fa1609f96398 100644
--- a/img_auth.php
+++ b/img_auth.php
@@ -162,13 +162,21 @@ function wfImageAuthMain() {
}
}
+ $options = []; // HTTP header options
+ if ( isset( $_SERVER['HTTP_RANGE'] ) ) {
+ $options['range'] = $_SERVER['HTTP_RANGE'];
+ }
+ if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
+ $options['if-modified-since'] = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
+ }
+
if ( $request->getCheck( 'download' ) ) {
$headers[] = 'Content-Disposition: attachment';
}
// Stream the requested file
wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." );
- $repo->streamFile( $filename, $headers );
+ $repo->streamFile( $filename, $headers, $options );
}
/**