HTTP proxy usage tweaks:
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 21 Mar 2009 00:01:44 +0000 (00:01 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 21 Mar 2009 00:01:44 +0000 (00:01 +0000)
* Use $wgHTTPProxy if set for Special:Upload upload-by-URL (it does its own CURL fetch instead of using Http class)
* Explicitly disable HTTP proxy for MWSearch fetches -- we know that'll be local network.

includes/specials/SpecialUpload.php

index 8849b55..7d28a38 100644 (file)
@@ -155,7 +155,7 @@ class UploadForm {
         * Returns true if there was an error, false otherwise
         */
        private function curlCopy( $url, $dest ) {
-               global $wgUser, $wgOut;
+               global $wgUser, $wgOut, $wgHTTPProxy;
 
                if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
                        $wgOut->permissionRequired( 'upload_by_url' );
@@ -183,6 +183,9 @@ class UploadForm {
                curl_setopt( $ch, CURLOPT_TIMEOUT, 10); # 10 seconds timeout
                curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512); # 0.5KB per second minimum transfer speed
                curl_setopt( $ch, CURLOPT_URL, $url);
+               if( $wgHTTPProxy ) {
+                       curl_setopt( $ch, CURLOPT_PROXY, $wgHTTPProxy );
+               }
                curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
                curl_exec( $ch );
                $error = curl_errno( $ch ) ? true : false;