r40720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40719‎ | r40720 | r40721 >
Date:00:29, 11 September 2008
Author:demon
Status:old
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -5,12 +5,12 @@
66 * @ingroup HTTP
77 */
88 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 );
1111 }
1212
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 );
1515 }
1616
1717 /**
@@ -18,7 +18,7 @@
1919 *
2020 * if $timeout is 'default', $wgHTTPTimeout is used
2121 */
22 - static function request( $method, $url, $timeout = 'default' ) {
 22+ static function request( $method, $url, $timeout = 'default', $curlOptions = array() ) {
2323 global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle;
2424
2525 wfDebug( __METHOD__ . ": $method $url\n" );
@@ -49,6 +49,12 @@
5050 if ( is_object( $wgTitle ) ) {
5151 curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
5252 }
 53+
 54+ if ( is_array( $curlOptions ) ) {
 55+ foreach( $curlOptions as $option => $value ) {
 56+ curl_setopt( $c, $option, $value );
 57+ }
 58+ }
5359
5460 ob_start();
5561 curl_exec( $c );

Status & tagging log