Merge "Make a VirtualRESTService class for Parsoid"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Jan 2015 01:29:44 +0000 (01:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Jan 2015 01:29:44 +0000 (01:29 +0000)
1  2 
autoload.php
includes/libs/MultiHttpClient.php

diff --combined autoload.php
@@@ -202,7 -202,6 +202,7 @@@ $wgAutoloadLocalClasses = array
        'ChangesListSpecialPage' => __DIR__ . '/includes/specialpage/ChangesListSpecialPage.php',
        'ChannelFeed' => __DIR__ . '/includes/Feed.php',
        'CheckBadRedirects' => __DIR__ . '/maintenance/checkBadRedirects.php',
 +      'CheckComposerLockUpToDate' => __DIR__ . '/maintenance/checkComposerLockUpToDate.php',
        'CheckExtensionsCLI' => __DIR__ . '/maintenance/language/checkLanguage.inc',
        'CheckImages' => __DIR__ . '/maintenance/checkImages.php',
        'CheckLanguageCLI' => __DIR__ . '/maintenance/language/checkLanguage.inc',
        'CompareParserCache' => __DIR__ . '/maintenance/compareParserCache.php',
        'CompareParsers' => __DIR__ . '/maintenance/compareParsers.php',
        'ComposerHookHandler' => __DIR__ . '/includes/composer/ComposerHookHandler.php',
 +      'ComposerJson' => __DIR__ . '/includes/libs/composer/ComposerJson.php',
 +      'ComposerLock' => __DIR__ . '/includes/libs/composer/ComposerLock.php',
        'ComposerPackageModifier' => __DIR__ . '/includes/composer/ComposerPackageModifier.php',
        'ComposerVersionNormalizer' => __DIR__ . '/includes/composer/ComposerVersionNormalizer.php',
        'CompressOld' => __DIR__ . '/maintenance/storage/compressOld.php',
        'ForeignDBFile' => __DIR__ . '/includes/filerepo/file/ForeignDBFile.php',
        'ForeignDBRepo' => __DIR__ . '/includes/filerepo/ForeignDBRepo.php',
        'ForeignDBViaLBRepo' => __DIR__ . '/includes/filerepo/ForeignDBViaLBRepo.php',
 +      'ForeignTitle' => __DIR__ . '/includes/title/ForeignTitle.php',
 +      'ForeignTitleFactory' => __DIR__ . '/includes/title/ForeignTitleFactory.php',
        'ForkController' => __DIR__ . '/includes/ForkController.php',
        'FormAction' => __DIR__ . '/includes/actions/FormAction.php',
        'FormOptions' => __DIR__ . '/includes/FormOptions.php',
        'ImportSiteScripts' => __DIR__ . '/maintenance/importSiteScripts.php',
        'ImportStreamSource' => __DIR__ . '/includes/Import.php',
        'ImportStringSource' => __DIR__ . '/includes/Import.php',
 +      'ImportTitleFactory' => __DIR__ . '/includes/title/ImportTitleFactory.php',
        'IncludableSpecialPage' => __DIR__ . '/includes/specialpage/IncludableSpecialPage.php',
        'IndexPager' => __DIR__ . '/includes/pager/IndexPager.php',
        'InfoAction' => __DIR__ . '/includes/actions/InfoAction.php',
        'MySqlLockManager' => __DIR__ . '/includes/filebackend/lockmanager/DBLockManager.php',
        'MysqlInstaller' => __DIR__ . '/includes/installer/MysqlInstaller.php',
        'MysqlUpdater' => __DIR__ . '/includes/installer/MysqlUpdater.php',
 +      'NaiveForeignTitleFactory' => __DIR__ . '/includes/title/NaiveForeignTitleFactory.php',
 +      'NaiveImportTitleFactory' => __DIR__ . '/includes/title/NaiveImportTitleFactory.php',
 +      'NamespaceAwareForeignTitleFactory' => __DIR__ . '/includes/title/NamespaceAwareForeignTitleFactory.php',
        'NamespaceConflictChecker' => __DIR__ . '/maintenance/namespaceDupes.php',
 +      'NamespaceImportTitleFactory' => __DIR__ . '/includes/title/NamespaceImportTitleFactory.php',
        'NewFilesPager' => __DIR__ . '/includes/specials/SpecialNewimages.php',
        'NewPagesPager' => __DIR__ . '/includes/specials/SpecialNewpages.php',
        'NewUsersLogFormatter' => __DIR__ . '/includes/logging/NewUsersLogFormatter.php',
        'ParserDiffTest' => __DIR__ . '/includes/parser/ParserDiffTest.php',
        'ParserOptions' => __DIR__ . '/includes/parser/ParserOptions.php',
        'ParserOutput' => __DIR__ . '/includes/parser/ParserOutput.php',
+       'ParsoidVirtualRESTService' => __DIR__ . '/includes/libs/virtualrest/ParsoidVirtualRESTService.php',
        'Password' => __DIR__ . '/includes/password/Password.php',
        'PasswordError' => __DIR__ . '/includes/password/PasswordError.php',
        'PasswordFactory' => __DIR__ . '/includes/password/PasswordFactory.php',
        'StubObject' => __DIR__ . '/includes/StubObject.php',
        'StubUserLang' => __DIR__ . '/includes/StubObject.php',
        'SubmitAction' => __DIR__ . '/includes/actions/SubmitAction.php',
 +      'SubpageImportTitleFactory' => __DIR__ . '/includes/title/SubpageImportTitleFactory.php',
        'SvgHandler' => __DIR__ . '/includes/media/SVG.php',
        'SwiftFileBackend' => __DIR__ . '/includes/filebackend/SwiftFileBackend.php',
        'SwiftFileBackendDirList' => __DIR__ . '/includes/filebackend/SwiftFileBackend.php',
@@@ -34,6 -34,7 +34,7 @@@
   *                array bodies are encoded as multipart/form-data and strings
   *                use application/x-www-form-urlencoded (headers sent automatically)
   *   - stream   : resource to stream the HTTP response body to
+  *   - proxy    : HTTP proxy to use
   * Request maps can use integer index 0 instead of 'method' and 1 instead of 'url'.
   *
   * @author Aaron Schulz
@@@ -52,14 -53,16 +53,17 @@@ class MultiHttpClient 
        protected $usePipelining = false;
        /** @var integer */
        protected $maxConnsPerHost = 50;
+       /** @var string|null proxy */
+       protected $proxy;
  
        /**
         * @param array $options
         *   - connTimeout     : default connection timeout
         *   - reqTimeout      : default request timeout
+        *   - proxy           : HTTP proxy to use
         *   - usePipelining   : whether to use HTTP pipelining if possible (for all hosts)
         *   - maxConnsPerHost : maximum number of concurrent connections (per host)
 +       * @throws Exception
         */
        public function __construct( array $options ) {
                if ( isset( $options['caBundlePath'] ) ) {
@@@ -68,7 -71,7 +72,7 @@@
                                throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath );
                        }
                }
-               static $opts = array( 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost' );
+               static $opts = array( 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy' );
                foreach ( $opts as $key ) {
                        if ( isset( $options[$key] ) ) {
                                $this->$key = $options[$key];
         * Execute a set of HTTP(S) requests concurrently
         *
         * The maps are returned by this method with the 'response' field set to a map of:
 -       *   - code    : HTTP response code or 0 if there was a serious cURL error
 -       *   - reason  : HTTP response reason (empty if there was a serious cURL error)
 -       *   - headers : <header name/value associative array>
 -       *   - body    : HTTP response body or resource (if "stream" was set)
 +       *   - code    : HTTP response code or 0 if there was a serious cURL error
 +       *   - reason  : HTTP response reason (empty if there was a serious cURL error)
 +       *   - headers : <header name/value associative array>
 +       *   - body    : HTTP response body or resource (if "stream" was set)
         *   - error   : Any cURL error string
 -       * The map also stores integer-indexed copies of these values. This lets callers do:
 -       *      <code>
 -       *              list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response'];
 +       * The map also stores integer-indexed copies of these values. This lets callers do:
 +       *    <code>
 +       *        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response'];
         *  </code>
         * All headers in the 'headers' field are normalized to use lower case names.
         * This is true for the request headers and the response headers. Integer-indexed
         *   - usePipelining   : whether to use HTTP pipelining if possible
         *   - maxConnsPerHost : maximum number of concurrent connections (per host)
         * @return array $reqs With response array populated for each
 +       * @throws Exception
         */
        public function runMulti( array $reqs, array $opts = array() ) {
                $chm = $this->getCurlMulti();
         *   - connTimeout    : default connection timeout
         *   - reqTimeout     : default request timeout
         * @return resource
 +       * @throws Exception
         */
        protected function getCurlHandle( array &$req, array $opts = array() ) {
                $ch = curl_init();
  
                curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT,
                        isset( $opts['connTimeout'] ) ? $opts['connTimeout'] : $this->connTimeout );
+               curl_setopt( $ch, CURLOPT_PROXY, isset( $req['proxy'] ) ? $req['proxy'] : $this->proxy );
                curl_setopt( $ch, CURLOPT_TIMEOUT,
                        isset( $opts['reqTimeout'] ) ? $opts['reqTimeout'] : $this->reqTimeout );
                curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );