X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialUploadStash.php;h=c278babd64fd1040a452769a48c64036f7aa3439;hb=0dba85432c7110907c32453b0438560411b67de2;hp=fe55d9427fb2c9d90014a3e5a703485b06ff266c;hpb=08f90e9bfe91b407fae72b7cd7156655dc75e642;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index fe55d9427f..c278babd64 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -261,6 +261,15 @@ class SpecialUploadStash extends UnlistedSpecialPage { $scalerThumbUrl = $scalerBaseUrl . '/' . $file->getUrlRel() . '/' . rawurlencode( $scalerThumbName ); + // If a thumb proxy is set up for the repo, we favor that, as that will + // keep the request internal + $thumbProxyUrl = $file->getRepo()->getThumbProxyUrl(); + + if ( strlen( $thumbProxyUrl ) ) { + $scalerThumbUrl = $thumbProxyUrl . 'temp/' . $file->getUrlRel() . + '/' . rawurlencode( $scalerThumbName ); + } + // make an http request based on wgUploadStashScalerBaseUrl to lazy-create // a thumbnail $httpOptions = [ @@ -268,6 +277,14 @@ class SpecialUploadStash extends UnlistedSpecialPage { 'timeout' => 5 // T90599 attempt to time out cleanly ]; $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions, __METHOD__ ); + + $secret = $file->getRepo()->getThumbProxySecret(); + + // Pass a secret key shared with the proxied service if any + if ( strlen( $secret ) ) { + $req->setHeader( 'X-Swift-Secret', $secret ); + } + $status = $req->execute(); if ( !$status->isOK() ) { $errors = $status->getErrorsArray(); @@ -305,10 +322,10 @@ class SpecialUploadStash extends UnlistedSpecialPage { ); } - return $file->getRepo()->streamFile( $file->getPath(), + return $file->getRepo()->streamFileWithStatus( $file->getPath(), [ 'Content-Transfer-Encoding: binary', 'Expires: Sun, 17-Jan-2038 19:14:07 GMT' ] - ); + )->isOK(); } /**