Index: trunk/phase3/includes/HttpFunctions.php |
— | — | @@ -5,12 +5,12 @@ |
6 | 6 | * @ingroup HTTP |
7 | 7 | */ |
8 | 8 | class Http { |
9 | | - static function get( $url, $timeout = 'default' ) { |
10 | | - return Http::request( "GET", $url, $timeout ); |
| 9 | + static function get( $url, $timeout = 'default', $opts = array() ) { |
| 10 | + return Http::request( "GET", $url, $timeout, $opts ); |
11 | 11 | } |
12 | 12 | |
13 | | - static function post( $url, $timeout = 'default' ) { |
14 | | - return Http::request( "POST", $url, $timeout ); |
| 13 | + static function post( $url, $timeout = 'default', $opts = array() ) { |
| 14 | + return Http::request( "POST", $url, $timeout, $opts ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * |
20 | 20 | * if $timeout is 'default', $wgHTTPTimeout is used |
21 | 21 | */ |
22 | | - static function request( $method, $url, $timeout = 'default' ) { |
| 22 | + static function request( $method, $url, $timeout = 'default', $curlOptions = array() ) { |
23 | 23 | global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle; |
24 | 24 | |
25 | 25 | wfDebug( __METHOD__ . ": $method $url\n" ); |
— | — | @@ -49,6 +49,12 @@ |
50 | 50 | if ( is_object( $wgTitle ) ) { |
51 | 51 | curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() ); |
52 | 52 | } |
| 53 | + |
| 54 | + if ( is_array( $curlOptions ) ) { |
| 55 | + foreach( $curlOptions as $option => $value ) { |
| 56 | + curl_setopt( $c, $option, $value ); |
| 57 | + } |
| 58 | + } |
53 | 59 | |
54 | 60 | ob_start(); |
55 | 61 | curl_exec( $c ); |