aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/MultiHttpClient.php
Commit message (Collapse)AuthorAgeFilesLines
* Move MultiHttpClient.php to libs/httpReedy2019-07-011-609/+0
| | | | Change-Id: I199e615fad363b1439604c9d01a9a475856d6128
* Collapse some nested if statementsReedy2019-04-041-5/+3
| | | | Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
* Revert "Convert MultiHttpClient to use Guzzle"Antoine Musso2019-03-061-168/+359
| | | | | | | | | | | | | | | | | | | | | | | That breaks on Wikimedia beta cluster (T217733): Warning: Invalid argument: option: 6 in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 56 Warning: Invalid argument: option: 6 in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 56 Warning: Invalid argument: function: not string, closure, or array in vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php on line 108 Fatal error: Uncaught exception 'ConfigException' Failed to load configuration from etcd: cURL error 23: Failed writing header This reverts commit 1e048a08b565ae909e85465f8b09a27ed8480ce2. Bug: T202352 Bug: T217733 Change-Id: I2384355043896128d3f191941e8da00fdc62361e
* Convert MultiHttpClient to use GuzzleBill Pirkle2019-03-051-359/+168
| | | | | | | | | Convert MultiHttpClient to use the Guzzle library. Guzzle includes built-in support for concurrency, and automatic fallback to php streams if curl is unavailable. Bug: T202352 Change-Id: I703af901f9da33d20b5e0989941f3f7fd6609298
* MultiHttpClient: Don't relay the end-of-headers lineBrad Jorsch2019-02-191-1/+1
| | | | | | | | | | | | | | | The callback registered by CURLOPT_HEADERFUNCTION is called for the empty line that separates the headers from the body, as well as all the actual headers. In this case, the $header string will be "\r\n". It turns out that HHVM ignores a call to header() when passed a string that's empty after trimming whitespace, while Zend PHP only ignores the call when the string is empty before trimming whitespace. This later causes problems when headers_list() is used expecting all strings returned to contain a colon. Bug: T216086 Change-Id: I07937b17beb06788166266fbb1ea1bbf456761e3
* Fix indenting and newlinesFomafix2018-11-071-1/+1
| | | | | | Like suggested in https://www.mediawiki.org/wiki/Manual:Coding_conventions#Line_continuation Change-Id: I86db3c24ffc69737c6917cfc68300ff4695961cd
* Added non-parallel fallback to MultiHttpClient when curl is unavailableBill Pirkle2018-07-231-62/+199
| | | | | | | | If the curl extension is not available, fall back to the existing HttpRequestFactory and associated classes. Also added related phpunit tests. Bug: T139169 Change-Id: I2f9d4acbb491bce28d7105e124c5cee7e16e86d7
* Improve timeouts in MultiHttpClientTim Starling2018-06-151-7/+36
| | | | | | | | | | | | * PHP 7 only checks for request/connection timeout after the timeout passed to curl_multi_select() expires. So it's necessary to use a select timeout which is much shorter than 10s. I filed https://bugs.php.net/bug.php?id=76480 for this. * Use millisecond resolution timeout parameters. These have been available since libcurl 7.16.2, released Jan 2008, available in Debian 7, Ubuntu 14.04 and CentOS 6. Change-Id: Ia07b824dde179b33e14b81a76d580ce547bca315
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-5/+5
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* Bump PHP version requirement to 7.0.0+James D. Forrester2018-05-241-10/+1
| | | | | Bug: T172165 Change-Id: I740f32ac859d9bb3787fdf8414f82ae6f410492f
* Autofix MediaWiki.Commenting.FunctionComment.SpacingDoc* errorsKunal Mehta2018-05-191-1/+1
| | | | Change-Id: I63761ebce04c03b9b13237919c27cc10180f198f
* Remove superfluous spaces and semicolons in commentsFomafix2018-02-051-1/+1
| | | | Change-Id: Ib4b452f1843ec250c8c1fcc2a738d80726b6135d
* Throw exception if php-curl is missingMoritz Schubotz (physikerwelt)2018-02-021-0/+5
| | | | | | | | | Currently MediaWiki just dies silently, if the php curl extension is missing. Throw an exception instead that redirects the admin to the appropriate help page. Change-Id: I25edfcb34ee5451a742cac6ae099019a16f6c417
* Use short type bool/int in param documentationUmherirrender2017-08-201-3/+3
| | | | | | Enable the phpcs sniffs for this and used phpcbf Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
* Use correct variable name in @param documentationUmherirrender2017-08-111-1/+1
| | | | | | | | | | | For some varargs a variable name is added with suffix ,... as seen for many other varargs Some @param are swapped, because there are in the wrong order Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
* Add missing & to @param documentation to match functon callUmherirrender2017-08-111-1/+1
| | | | Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
* Remove "@author Aaron Schulz" annotationsAaron Schulz2017-06-271-1/+0
| | | | | Bug: T139301 Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
* Improve HTTP loggingTim Starling2017-05-191-2/+24
| | | | | | | | | | | | | * Log HTTP debug lines to the "http" channel instead of wfDebug() * Add the ability to do debug logging to MultiHttpClient * Add a static method Http::createMultiClient() which provides a MultiHttpClient configured similarly to the way individual requests are configured, respecting the wiki's $wgHTTPTimeout and writing debug logs. * In EtcdConfig, pass the logger instance through to the MultiHttpClient backend. Change-Id: Ic5bdcb0cae95d7b3715ab5261758be082751c3ff
* Update weblinks in comments from HTTP to HTTPSFomafix2016-11-071-1/+1
| | | | | | | | Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link. Also update some defect links. Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
* Remove pre-5.5 compat from MultiHttpClientKunal Mehta2016-10-011-22/+11
| | | | Change-Id: I5f9f1a94c0207a14c0d5cc77292aa04af4ac6470
* MultiHttpClient: Don't use wfArrayToCgi()Kunal Mehta2016-09-201-1/+1
| | | | | | http_build_query() should be functionally identical. Change-Id: Ia7d909e97a89d66dbe5187e9a0423e2ecf8561e8
* Merge "Added Range support to FileBackend::streamFile()"Brion VIBBER2016-07-191-0/+6
|\
| * Added Range support to FileBackend::streamFile()Aaron Schulz2016-06-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added HTTP options headers parameter to streamFile(). * Refactored doStreamFile() to either call StreamFile::stream() or delagate that to the subclass. SwiftFileBackend now relays the full Swift response rather than manually making the headers. This also makes Range headers easy to support. * Made use of this in img_auth.php for performance on private wikis. * Elimate stat call in streamFile() for Swift if "headers" is empty. * Refactored StreamFile a bit to inject request headers instead of using the $_SERVER global. A header options parameter is used instead, which also supports Range. * Removed now unused prepareForStream(). * Cleaned up streamFile() unit tests. Change-Id: I2ccbcbca6caabb8cf65bd6b3084cede2e6ea628a
* | Create BagOStuff implementation to talk to RestBaseStanislav Malyshev2016-07-061-1/+1
|/ | | | | | | Or any other HTTP REST server. Bug: T137272 Change-Id: Iefef24ffa831ba59d7725da8d20d5addb544b3ab
* Improve code suffering from PHP 5.3's lack of support for foo()[]Bartosz Dziewoński2016-02-281-2/+1
| | | | | | | | | I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored everything involving isset(), unset() or array assigments, then skimmed through the remaining results and changed things where they made sense. These changes were not automated, so please review them. Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
* Convert all array() syntax to []Kunal Mehta2016-02-171-17/+17
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* SECURITY: Work around CURL insanity breaking POST parameters that start with '@'Roan Kattouw2015-12-181-0/+13
| | | | | | | | | | | | | | | | | | | | | | | CURL has a "feature" where passing array( 'foo' => '@bar' ) in CURLOPT_POSTFIELDS results in the contents of the file named "bar" being POSTed. This makes it impossible to POST the literal string "@bar", because array( 'foo' => '%40bar' ) gets double-encoded to foo=%2540bar. Disable this "feature" by setting CURLOPT_SAFE_UPLOAD to true, if available. According to the PHP manual, this option became available in 5.5 and started defaulting to true in 5.6. However, we support versions as low as 5.3, and this option doesn't exist at all in 5.6.99-hhvm, which we run in production. For versions where this option is not available (pre-5.5 versions and HHVM), serialize POSTFIELDS arrays to strings. This works around the issue because the '@' "feature" only works for arrays, not strings, as of PHP 5.2. (We don't support pre-5.2 versions, and I've verified 5.6.99-hhvm behaves this way as well.) Bug: T118032 Signed-off-by: Chad Horohoe <chadh@wikimedia.org> Change-Id: I3f996e2eb87c7bd3b94ca9d3cc14a3e12f34f241
* Restore "userAgent" MultiHttpClient constructor overrideAaron Schulz2015-10-061-9/+3
| | | | | | This is more convenient than needing to set it on each HTTP request. Also, it is still documented as being there. Change-Id: I246c9c3861d72701c844200b82d1a38a0c301795
* MultiHttpClient: Don't use "MW" in User-AgentTimo Tijhof2015-10-061-3/+9
| | | | | | Follows-up 6f51037d680ce. Change-Id: I5e404c3a6ab9c3d1126676ee5fc22149422aa51f
* Add User-Agent support to MultiHttpClient requestsTim Starling2015-10-061-1/+8
| | | | | | | Because it is polite to send a User-Agent (and as part of T114558 investigation). Change-Id: I5096896d0891c0c9674ff8b4284aaa3ac7293c67
* Fixed occasional MultiHttpClient "undefined index" errorsAaron Schulz2015-08-061-9/+13
| | | | | | * These show sometimes in Swift FileBackend tests Change-Id: I38c1817812282c94cab2011da7c322e92eec96ca
* Use feature test rather than version checkNiklas Laxström2015-07-221-1/+1
| | | | | | | Not sure why I didn't do this in the first place. Bug: T106579 Change-Id: I238aedacd4f960ad4ca7549c232fd3a7eec3f02f
* Merge "Fix MultiHttpClient to return correct errors"jenkins-bot2015-07-141-3/+16
|\
| * Fix MultiHttpClient to return correct errorsNiklas Laxström2015-07-141-3/+16
| | | | | | | | | | Bug: T89758 Change-Id: Ia1f1986d150df1a9f463d48f1a914a04608550f8
* | Change spaces to tabsVivek Ghaisas2015-06-211-5/+5
|/ | | | | Bug: T103243 Change-Id: I145c056ef1b058c9c24b4a402ac9e7778b23e260
* Fixed some <code> tags for doxygenAaron Schulz2015-04-291-4/+4
| | | | Change-Id: I550b8760556e4916ee9b63ee244bbbcb4d926142
* Document units in MultiHttpClientAaron Schulz2015-04-201-6/+6
| | | | Change-Id: I0350e4e558f881e3accd01818a56e11465d92d00
* Merge "Make a VirtualRESTService class for Parsoid"jenkins-bot2015-01-071-1/+6
|\
| * Make a VirtualRESTService class for ParsoidAlex Monk2015-01-071-1/+6
| | | | | | | | | | | | | | | | | | So that code to deal with Parsoid can be shared across different extensions. Relies on I1d57ff24 Bug: T1218 Change-Id: Id658d925b722b885fd425c27f7c4fd2cd02ad0b4
* | Add lots of @throwsReedy2014-12-241-7/+10
|/ | | | Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
* Fix error in docs of VirtualRESTServiceClient and MultiHttpClientAlex Monk2014-12-191-2/+2
| | | | | | err -> error Change-Id: I758c026599367b282150a513b09d6f6c837a3a80
* Fixed doc commentAaron Schulz2014-08-141-1/+1
| | | | Change-Id: I906f3f34ac27207dd6b87b07fa6e791bc7b66691
* Added VirtualRESTServiceClient/VirtualRESTService classesAaron Schulz2014-04-291-2/+2
| | | | | | | | * Reference handling cleanup for loops in MultiHttpClient * Support a slightly more convenient request array format for MultiHttpClient * Added missing license header to MultiHttpClient Change-Id: Icc86ed9e4c2ac78363aa7b6f3147253bb59e2afb
* Set the "error" field in the right arrayAaron Schulz2014-04-071-1/+2
| | | | Change-Id: Id822ceb53c57daac0000bef3b304bb0260efe4ce
* MultiHttpClient tweaksAaron Schulz2014-02-111-4/+36
| | | | | | | | * Reference handling cleanup for loops in MultiHttpClient * Support a slightly more convenient request array format for MultiHttpClient * Added missing license header to MultiHttpClient Change-Id: I0a2eef02c06d9c900c4a1ae1b0eeb292755d6cd9
* Added pipelining and max connection support to MultiHttpClientAaron Schulz2014-02-101-29/+82
| | | | | | * Also added timeout options to the run()/runMulti() methods Change-Id: I2b080567e17fa29804c36e3b259b1ce214e6f465
* Fixed http_build_query warnings on PHP < 5.4Aaron Schulz2014-01-091-3/+10
| | | | | | * bug: 59880 Change-Id: I2eae4bed17a72b58ac33f3538dd7d16f4356a3a0
* Removed cloudfiles dependency in SwiftFileBackendAaron Schulz2014-01-071-0/+296
* Added a new curl multi wrapper under libs/. * Used the new MultiHttpClient class instead of CloudFiles * Removed CDN related config and code as it does not work. well due to mutating files and tiny purge rate limits by CDNs. * Also removed the unused and esoteric 'swiftAnonUser' parameter. * Support concurrent 'describe' operations. * Set ACLs on containers on intial PUT instead of in two steps. Previously if the second step failed, prepare() would never set the ACLs correctly since it aborts if the container exists. * Improve token deletion to only trigger on 401s rather than other random errors like 50X timeouts. * Removed duplicative getResponse* code by just using one closure called for both the concurrent and serial cases. Both cases are now funneled through doExecuteOpHandlesInternal(). * Add the MD5 to stat info, as it might be useful for speeding up the copy scripts in some cases (when both backends have md5 set). * Avoid use of trigger_error() since there is a swift log group. * A few other small code cleanups. Change-Id: I1adb3e2df6df8cf01d3ad74158de96ea9a79da2e