aboutsummaryrefslogtreecommitdiffstats
path: root/includes/http/MWHttpRequest.php
Commit message (Collapse)AuthorAgeFilesLines
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Add @phan-mandatory-param for function name argumentsUmherirrender2024-09-201-1/+1
| | | | | | | | | | | Providing the function name is often optional from the php code, but it is needed for better logging, so make it mandatory and let phan report issues about this. Bug: T374546 Depends-On: Iaed5489a85a5a6e685829e151436afc94310fbd0 Depends-On: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d Change-Id: I5227f2fa65850ac8c6f620900f22d1f4e7bfd470
* http: Add missing documentation to class propertiesUmherirrender2024-09-141-0/+17
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I6dd402a5bca0c2136595faedae315959bbcf17d9
* Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()James D. Forrester2024-09-101-3/+3
| | | | | | | | | | | | | | wfGetUrlUtils() is also deprecated, but less so, so we can do this first and then properly replace the individual uses with dependency injection in local pieces of work. Also: * Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList exposed a type error in media.txt where $wgNoFollowDomainExceptions was set to a string (which is invalid) instead of an array. Bug: T319340 Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
* Avoid use of deprecated global functions in MWHttpRequestEbrahim Byagowi2024-09-091-4/+8
| | | | | Bug: T319340 Change-Id: I757180bd8aa59bd51bd42661724dc99f8d56016f
* MWHttpRequest: Drop support for creating without timeout or ↵Piotr Miazga2024-05-051-22/+8
| | | | | | | | | | | connectionTimeout, deprecated in 1.35 In 1.35 we deprecated not passing the timeout and connectionTimeout settings when constructing the MWHttpRequest object. Upgrade hard-deprecation via wfDeprecated() to instead throw an InvalidArgumentException. Change-Id: I260469c6235fa9022b264757b0a17d498cee1396
* build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manuallyJames D. Forrester2024-02-101-1/+1
| | | | | | | | | | | * Switch out raw Exceptions, mostly for InvalidArgumentExceptions. * Fake exceptions triggered to give Monolog a backtrace are for some reason "traditionally" RuntimeExceptions, instead, so we continue to use that pattern in remaining locations. * Just entirely give up on PostgresResultWrapper's resource vs. object mess. * Drop now-unneeded false positive hits. Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
* Replace $wgCommandLineMode checks with MW_ENTRY_POINT in other placesBartosz Dziewoński2024-01-021-4/+3
| | | | | | | | I'm not sure if there's a good way to split this up into logical chunks. Bug: T313841 Change-Id: I3b35a2e475b5143f383d4085fbc6a0ed3bbc32b8
* Merge "http: MultiHttpClient supports TelemetryHeadersInterface"jenkins-bot2023-09-121-11/+5
|\
| * http: MultiHttpClient supports TelemetryHeadersInterfacePiotr Miazga2023-09-121-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new interface Wikimedia/Http/TelemetryHeadersInterface that provides telemetry information that could be attached to HTTP Requests. MultiHttpClient is expecting `telemetry` option of TelemetryHeadersInterface type. The MediaWiki/Http/Telemetry implements the interface, therefore ObjectCache can inject it to RESTBagOStuff, that further injects it to MultiHttpClient. Bug: T344926 Change-Id: I59a3f1048c403fe2e4ef0c74353dfe74ff9ca893
* | Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-111-0/+1
|/ | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-251-0/+1
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* http: Propagate `tracestate` and `traceparent` headersPiotr Miazga2023-08-071-2/+19
| | | | | | | | | | | Introduce a Telemetry singleton for propagating `tracestate` and `traceheaders` during a MW web request. This class allows for easier testing and mocking. In the future we might use this as a wrapper for OpenTelemetry. Bug: T320559 Change-Id: I3e5e54afa21f8c099877b3765c769f2d2f8f5d61
* Remove deprecated MWHttpRequest::factoryUmherirrender2023-04-261-16/+0
| | | | | Bug: T324918 Change-Id: Ie03d4b25eb239bbbbc2346821a86f09c29e03524
* Hard-deprecate MWHttpRequest::factoryUmherirrender2023-02-131-1/+2
| | | | | Bug: T324918 Change-Id: I360d57b5aa9e2e8cbfc8b5c5654ab1aaf1d944b3
* Make use of ?:, ?? and ??= operators in mostly trivial casesthiemowmde2022-12-051-4/+1
| | | | | | | | | | The motivation is to make the code less confusing. I hope this is the case. ?? is an older PHP 7.0 feature. ??= was added in PHP 7.4, which we can finally use. Change-Id: Id807affa52bd1151a74c064623b41d950a389560
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-3/+2
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-2/+3
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* Use short array destructuring instead of list()Tim Starling2022-10-211-1/+1
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* Use MainConfigNames instead of string literalsAryeh Gregor2022-04-111-5/+11
| | | | | | | | Part 1, proof of concept. Hundreds of files left to go. These changes brought to you in large part by vim macros. Bug: T305805 Change-Id: I44789091e9f6394c800a11b29f22528c8dcacf71
* Merge "phan: Remove PhanTypePossiblyInvalidDimOffset suppression"jenkins-bot2022-03-291-0/+1
|\
| * phan: Remove PhanTypePossiblyInvalidDimOffset suppressionUmherirrender2022-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | Make phan stricter about array keys Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T304887 Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1 Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385 Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
* | Check return of parse_url for used url partsUmherirrender2022-03-291-4/+8
|/ | | | | | Found by phan (T304887) Change-Id: I3105a5fd4826f8667b5232834defc5ec93be32a1
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-12/+13
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* http: Don't set X-Forwarded-Proto when using a reverse proxyKunal Mehta2021-11-171-3/+0
| | | | | | | | | | | Discussion on Ia16d8f86b1cb20 indicates that we want to go in the other direction - MediaWiki shouldn't set X-Forwarded-Proto, rather the reverse proxy (envoy in Wikimedia's case) should set it. This follows-up cc241c2add4ebdd. Bug: T288848 Change-Id: Ifc5e9da9a02b45d9d1ad51c3e1389f9ac7325c86
* Allow using a reverse proxy for local HTTP requestsKunal Mehta2021-10-151-1/+36
| | | | | | | | | | | | | | $wgLocalHTTPProxy can be used to configure a reverse proxy for requests to domains in $wgLocalVirtualHosts. The previous implementation of using it as a proper HTTP proxy is no longer supported and has been reverted out of REL1_37 (856da72363d1ba8bf). It sets the hostname of the request as a "Host" header, scheme as "X-Forwarded-Proto" and then sets the proxy's scheme, host and port as those of the request. Bug: T288848 Change-Id: Ibc3616f5ad925d464d937ab15461a88619c8b7a7
* http: Add $wgLocalHTTPProxy to set a proxy for local requestsKunal Mehta2021-08-191-7/+13
| | | | | | | | | | | | | Currently requests to domains listed in $wgLocalVirtualHosts bypass use of the standard $wgHttpProxy. With WMF's migration to Kubernetes, we limit outgoing traffic in a much stricter manner, so even internal requests will need to go over a proxy (e.g. Envoy). If the domain passes MWHttpRequest::isLocalURL(), then $wgLocalHTTPProxy will be used if set, otherwise no proxy will be used (current behavior). Bug: T288848 Change-Id: Ifd0cbab02fa8f14a82ca34ebc7ad95b2be174434
* Remove dead variables and functions and unneeded parenthesisUmherirrender2021-08-131-1/+1
| | | | | | Found by sonarqube Change-Id: I3464d25e94d98aaca55d9209d5175542b335f994
* build: Swap deprecated @codingStandardsIgnore to phpcs:ignoreUmherirrender2021-04-041-2/+1
| | | | | Bug: T278594 Change-Id: I09a6175917090593e6e0055203a890c32bea03a5
* Remove documentation that literally repeats the codeThiemo Kreuz2020-10-271-1/+0
| | | | | | | | | | | | | | | For example, documenting the method getUser() with "get the User object" does not add any information that's not already there. But I have to read the text first to understand that it doesn't document anything that's not already obvious from the code. Some of this is from a time when we had a PHPCS sniff that was complaining when a line like `@param User $user` doesn't end with some descriptive text. Some users started adding text like `@param User $user The User` back then. Let's please remove this. Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
* Respect configured default HTTP timeouts, and introduce max timeoutsTim Starling2020-05-211-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add HttpRequestFactory::createMultiClient(), which returns a MultiHttpClient with configured defaults applied. This is similar to the recently-deprecated Http::createMultiClient(). * Introduce $wgHTTPMaxTimeout and $wgHTTPMaxConnectTimeout which, if set to a lower value than their defaults of infinity, will limit the applied HTTP timeouts, whether configured or passed on a per-request basis. This is based on the frequently correct assumption that ops know more about timeouts than developers. * In case developers believe, after becoming aware of this new situation, that they actually do know more about timeouts than ops, it is possible to override the configured maximum by passing similarly named options to HttpRequestFactory::createMultiClient() and HttpRequestFactory::create(). * Apply modern standards to HttpRequestFactory by injecting a logger and all configuration parameters used by its backends. * As in Http, the new createMultiClient() will use a MediaWiki/1.35 User-Agent and the 'http' channel for logging. * Document that no proxy will be used for createMultiClient(). Proxy config is weird and was previously a good reason to use MultiHttpClient over HttpRequestFactory. * Deprecate direct construction of MWHttpRequest without a timeout parameter Bug: T245170 Change-Id: I8252f6c854b98059f4916d5460ea71cf4b580149
* Fix even more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-161-1/+1
| | | | Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUseJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
* build: Upgrade phan to 0.9.0Daimona Eaytoy2019-12-071-1/+0
| | | | | | | | | | | | | | | Scalar casts are still allowed (for now), because there's a huge amount of false positives. Ditto for invalid array offsets. Thoughts about the rest: luckily, many false positives with array offsets have gone. Moreover, since *Internal issues are suppressed in the base config, we can remove inline suppressions. Unfortunately, there are a couple of new issues about array additions with only false positives, because apparently they don't take branches into account. Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
* Remove unneeded return from MWHttpRequest::setCallbackUmherirrender2019-11-081-1/+1
| | | | | | doSetCallback has no return value Change-Id: Ifaf5c62d72bf7214a8733f7482adbbe033958f2e
* MWHttpRequest: Avoid usage of deprecated Http class methodsDerick Alangi2019-10-091-4/+5
| | | | Change-Id: Id0837874896708adf4a950d3bd74ae92f4908851
* Fix type for timeout and connectTimeout in HttpRequestFactory::createUmherirrender2019-09-231-1/+1
| | | | | | Both can have a string 'default' Change-Id: I9c49cf7db762f251b010bc5469d4c1b4a7797f45
* Upgrade phan config to 0.7.1Daimona Eaytoy2019-09-041-1/+0
| | | | | | | | This allows us to remove many suppressions for phan false positives. Bug: T231636 Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065 Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
* Unsuppress another phan issue (part 7)Daimona Eaytoy2019-09-031-1/+1
| | | | | | | Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
* Unsuppress phan issues part 6Daimona Eaytoy2019-09-011-0/+7
| | | | | | Bug: T231636 Depends-On: I50377746f01749b058c39fd8229f9d566224cc43 Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
* Deprecate the Http classAryeh Gregor2019-05-061-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | All methods got moved to HttpRequestFactory or MWHttpRequest or dropped. I made the return value of the new HttpRequestFactory::request/get/post methods null on error instead of false, so that when we drop PHP 7 support, we can use a "?string" return value. This could theoretically change behavior of code that was switched from the old Http methods, but probably won't. I kept the old behavior for the deprecated methods. I changed the default value of $wgHTTPProxy from false to ''. This way it should be usable directly without a trivial wrapper method. For the benefit of anyone who might have set it to false in LocalSettings.php, I also recommend casting to string just in case. Http::$httpEngine is deprecated. Eventually it will be removed along with the curl and PHP engines, leaving only the Guzlle engine. I also added deprecation of MWHttpRequest::factory, which occurred in 1.31, to the release notes for 1.34. Now hopefully we can hard-deprecate it in another couple of versions. Bug: T214390 Change-Id: I2a316a758d793857f248bd251b90f5e9a6440e3a
* MWHttpRequest: Include the request ID in outgoing HTTP requestsMarko Obrovac2019-02-081-0/+2
| | | | | | | | In order to be able to trace requests across the production environment, we attach the X-Request-Id to outgoing requests. Bug: T201409 Change-Id: Iadd6cbd51a78a1876a1a318783b51635717d054f
* Fix @param tagsFomafix2019-02-031-1/+1
| | | | | | | | * Use 'callable' instead of 'callback'. * Remove '$' as part of a type name. * Add missing type. Change-Id: Ic1b39a7d8cbbee000d8fb2f3a1f71a621bd01993
* http: Support callback functions in GuzzleHttpRequestBill Pirkle2019-01-241-5/+16
| | | | | | | | | | Provide backward compatibility for callback functions in GuzzleHttpRequest, which was missing in T202110, and restore GuzzleHttpRequest as the default provided by HttpRequestFactory. Bug: T212175 Depends-On: I4b45e79d35252d13f714f3271b87301ca515121a Change-Id: I60d1a034b44874f6d24a04058db264eeb565f5e1
* Document header case in MWHttpRequestLucas Werkmeister2019-01-211-1/+2
| | | | | | | The lack of this documentation resulted in some confusion in T214032 and related tasks. Change-Id: I08fc201b625197614ef5e163ed3686638b630b13
* Fix exception on certain http failuresBill Pirkle2018-12-141-1/+1
| | | | | | | | | | Task T202110 included a change to recognize an HTTP status code of 0 (zero) as an error, but it failed to set a status message, resulting in an exception. Changed to set a status message of 'Error' so that required value is not empty. Bug: T212005 Change-Id: I5fb78555bfcaeccdd726432f4dfc70924a385c41
* Create GuzzleHttpRequest class as new default for HttpRequestFactoryBill Pirkle2018-12-101-5/+8
| | | | | | | | | | | Create a GuzzleHttpRequest class using the external Guzzle (docs.guzzlephp.org) library. This will be the new default request type, but CurlHttpRequest and PhpHttpRequest remain available and accessible via Http::$httpEngine. Bug: T202110 Change-Id: Ie720be2628d7baf427b002847f103fd86ee4cff3 Depends-On: I143a6410d111e75f01dbbfd43f300e2e60247451
* Use PHP 7 '??' operator instead of if-then-elseFomafix2018-10-211-5/+1
| | | | Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
* Added non-parallel fallback to MultiHttpClient when curl is unavailableBill Pirkle2018-07-231-0/+6
| | | | | | | | 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