Add $options param to Http::get() and friends. Now things don't need to use curl...
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 11 Sep 2008 00:29:51 +0000 (00:29 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 11 Sep 2008 00:29:51 +0000 (00:29 +0000)
includes/HttpFunctions.php

index 8ae4d2d..c055d2e 100644 (file)
@@ -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 );