From 4b58dcbab14598bc4a1e21fb7ed4c13a71ef910d Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Fri, 21 Mar 2014 23:23:55 -0300 Subject: [PATCH] Add support for specifying headers in FileRepo::quickImport Previously only content-disposition headers were allowed. This is needed so that TimedMediaHandler can put X-Content-Duration headers on ogg transcodes. Bug: 62928 Change-Id: Ic053be63b3edf348da95a88fc494fcf334430265 --- includes/filerepo/FileRepo.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 534d7f2212..888af377be 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -966,11 +966,13 @@ class FileRepo { * * @param string $src Source file system path, storage path, or virtual URL * @param string $dst Virtual URL or storage path - * @param string|null $disposition Content-Disposition if given and supported + * @param Array|string|null $options An array consisting of a key named headers + * listing extra headers. If a string, taken as content-disposition header. + * (Support for array of options new in 1.23) * @return FileRepoStatus */ - final public function quickImport( $src, $dst, $disposition = null ) { - return $this->quickImportBatch( array( array( $src, $dst, $disposition ) ) ); + final public function quickImport( $src, $dst, $options = null ) { + return $this->quickImportBatch( array( array( $src, $dst, $options ) ) ); } /** @@ -1007,7 +1009,7 @@ class FileRepo { * This is intended for copying generated thumbnails into the repo. * * All path parameters may be a file system path, storage path, or virtual URL. - * When "dispositions" are given they are used as Content-Disposition if supported. + * When "headers" are given they are used as HTTP headers if supported. * * @param array $triples List of (source path, destination path, disposition) * @return FileRepoStatus @@ -1019,11 +1021,20 @@ class FileRepo { list( $src, $dst ) = $triple; $src = $this->resolveToStoragePath( $src ); $dst = $this->resolveToStoragePath( $dst ); + + if ( !isset( $triple[2] ) ) { + $headers = array(); + } elseif ( is_string( $triple[2] ) ) { + // back-compat + $headers = array( 'Content-Disposition' => $triple[2] ); + } elseif ( is_array( $triple[2] ) && isset( $triple[2]['headers'] ) ) { + $headers = $triple[2]['headers']; + } $operations[] = array( 'op' => FileBackend::isStoragePath( $src ) ? 'copy' : 'store', 'src' => $src, 'dst' => $dst, - 'disposition' => isset( $triple[2] ) ? $triple[2] : null + 'headers' => $headers ); $status->merge( $this->initDirectory( dirname( $dst ) ) ); } -- 2.20.1