r53330 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53329‎ | r53330 | r53331 >
Date:20:50, 15 July 2009
Author:dale
Status:ok
Tags:
Comment:
restored bc for Http::request per comments on r53282
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -11,34 +11,36 @@
1212 const ASYNC_DOWNLOAD = 2; // asynchronous upload we should spawn out another process and monitor progress if possible)
1313
1414 var $body = '';
15 - public static function request( $url, $opts = array() ) {
 15+ public static function request($method, $url, $opts = Array() ){
 16+ $opts['method'] = ( strtoupper( $method ) == 'GET' || strtoupper( $method ) == 'POST' ) ? strtoupper( $method ) : null;
1617 $req = new HttpRequest( $url, $opts );
1718 $status = $req->doRequest();
1819 if( $status->isOK() ){
1920 return $status->value;
2021 } else {
 22+ wfDebug( 'http error: ' . $status->getWikiText() );
2123 return false;
2224 }
2325 }
24 -
2526 /**
2627 * Simple wrapper for Http::request( 'GET' )
2728 */
28 - public static function get( $url, $opts = array() ) {
29 - $opt['method'] = 'GET';
30 - return Http::request( $url, $opts );
 29+ public static function get( $url, $timeout = false) {
 30+ $opts = Array();
 31+ if( $timeout )
 32+ $opts['timeout'] = $timeout;
 33+ return Http::request( 'GET', $url, $opts );
3134 }
3235
3336 /**
3437 * Simple wrapper for Http::request( 'POST' )
3538 */
3639 public static function post( $url, $opts = array() ) {
37 - $opts['method'] = 'POST';
38 - return Http::request( $url, $opts );
 40+ return Http::request( 'POST', $url, $opts );
3941 }
4042
4143 public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount = 0 ){
42 - global $wgPhpCliPath, $wgMaxUploadSize, $wgMaxRedirects;
 44+ global $wgPhpCli, $wgMaxUploadSize, $wgMaxRedirects;
4345 // do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
4446 $head = get_headers( $url, 1 );
4547
@@ -67,7 +69,7 @@
6870 }
6971
7072 // check if we can find phpCliPath (for doing a background shell request to php to do the download:
71 - if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD ){
 73+ if( $wgPhpCli && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD ){
7274 wfDebug( __METHOD__ . "\ASYNC_DOWNLOAD\n" );
7375 // setup session and shell call:
7476 return self::initBackgroundDownload( $url, $target_file_path, $content_length );
@@ -87,7 +89,7 @@
8890 *
8991 */
9092 private function initBackgroundDownload( $url, $target_file_path, $content_length = null ){
91 - global $wgMaxUploadSize, $IP, $wgPhpCliPath;
 93+ global $wgMaxUploadSize, $IP, $wgPhpCli;
9294 $status = Status::newGood();
9395
9496 // generate a session id with all the details for the download (pid, target_file_path )
@@ -105,7 +107,7 @@
106108 $_SESSION['wsDownload'][$upload_session_key]['loaded'] = 0;
107109
108110 // run the background download request:
109 - $cmd = $wgPhpCliPath . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
 111+ $cmd = $wgPhpCli . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
110112 $pid = wfShellBackgroundExec( $cmd, $retval );
111113 // the pid is not of much use since we won't be visiting this same apache any-time soon.
112114 if( !$pid )

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53282here it is ... the upload-api, script-server, js2 (javascript phase2) branch ...dale23:52, 14 July 2009

Status & tagging log