diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2014-04-20 01:40:06 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2016-06-04 05:43:43 -0700 |
commit | d42a05475a1fec48de72fdee961de66c1af2279a (patch) | |
tree | 27079d0a19d57dc0dcfc3b6fb6b3263924679d2b /img_auth.php | |
parent | 633c0da23af1cdb16f8edb6252f1c1138422162c (diff) | |
download | mediawikicore-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.php | 10 |
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 ); } /** |