From: Neil Kandalgaonkar Date: Tue, 30 Nov 2010 04:40:34 +0000 (+0000) Subject: better error checking, fixed a few bugs with remote content scaling X-Git-Tag: 1.31.0-rc.0~33686 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=a09be5fd876426e2c392a955f9ed1b31fa2fdc9d;p=lhc%2Fweb%2Fwiklou.git better error checking, fixed a few bugs with remote content scaling --- diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index a64e0f8e3d..032c862cd8 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -194,16 +194,22 @@ class SpecialUploadStash extends UnlistedSpecialPage { $scalerThumbUrl = $wgUploadStashScalerBaseUrl . '/' . $file->getRel() . '/' . $scalerThumbName; // make a CURL call to the scaler to create a thumbnail wfDebug( "UploadStash: calling " . $scalerThumbUrl . " with curl \n" ); - $req = MWHttpRequest::factory( $thumbScalerUrl ); + + $httpOptions = array( + 'method' => 'GET', + 'timeout' => 'default' + ); + $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions ); $status = $req->execute(); if ( ! $status->isOK() ) { - throw new MWException( "Fetching thumbnail failed" ); - } + $errors = $status->getErrorsArray(); + throw new MWException( "Fetching thumbnail failed: " . join( ", ", $errors ) ); + } $contentType = $req->getResponseHeader( "content-type" ); if ( ! $contentType ) { throw new MWException( "Missing content-type header" ); } - return $this->outputFromContent( $req->getContent(), $contentType ); + return $this->outputContents( $req->getContent(), $contentType ); } /** @@ -245,7 +251,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { * @param String $size: length in bytes */ private static function outputHeaders( $contentType, $size ) { - header( "Content-Type: $mimeType", true ); + header( "Content-Type: $contentType", true ); header( 'Content-Transfer-Encoding: binary', true ); header( 'Expires: Sun, 17-Jan-2038 19:14:07 GMT', true ); header( "Content-Length: $size", true );