From fa6d8c3dbae3413a694a28c0b0d2d7be34fe1353 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 11 Sep 2008 00:29:51 +0000 Subject: [PATCH] Add $options param to Http::get() and friends. Now things don't need to use curl directly just because they want to set specific options not set by default (I'm eying you, UploadFromUrl and SpecialUpload). --- includes/HttpFunctions.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 8ae4d2dfa1..c055d2e0f2 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -5,12 +5,12 @@ * @ingroup HTTP */ class Http { - static function get( $url, $timeout = 'default' ) { - return Http::request( "GET", $url, $timeout ); + static function get( $url, $timeout = 'default', $opts = array() ) { + return Http::request( "GET", $url, $timeout, $opts ); } - static function post( $url, $timeout = 'default' ) { - return Http::request( "POST", $url, $timeout ); + static function post( $url, $timeout = 'default', $opts = array() ) { + return Http::request( "POST", $url, $timeout, $opts ); } /** @@ -18,7 +18,7 @@ class Http { * * if $timeout is 'default', $wgHTTPTimeout is used */ - static function request( $method, $url, $timeout = 'default' ) { + static function request( $method, $url, $timeout = 'default', $curlOptions = array() ) { global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle; wfDebug( __METHOD__ . ": $method $url\n" ); @@ -49,6 +49,12 @@ class Http { if ( is_object( $wgTitle ) ) { curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() ); } + + if ( is_array( $curlOptions ) ) { + foreach( $curlOptions as $option => $value ) { + curl_setopt( $c, $option, $value ); + } + } ob_start(); curl_exec( $c ); -- 2.20.1