aboutsummaryrefslogtreecommitdiffstats
path: root/includes/http/GuzzleHttpRequest.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
* Merge "http: Remove timestamp from 'http' channel logs"jenkins-bot2024-09-171-1/+1
|\
| * http: Remove timestamp from 'http' channel logsBartosz Dziewoński2024-09-171-1/+1
| | | | | | | | | | | | | | | | The timestamp is redundant with the timestamp that should be injected by the log formatter, and it makes it more difficult to find identical log messages. Change-Id: Ifa0529a5f8233be5adc16fa7632542f39916fda9
* | Remove unchecked exception annotationsAdam Wight2024-09-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers should not catch an unchecked exception, so it doesn't belong in a function signature. Unchecked exceptions indicate a coding error, which by definition the code will not be able to handle correctly. If any of these exceptions were supposed to be in response to an edge case, user input, or initial conditions, then they should be changed to a runtime error. If the exception class cannot be changed, then the annotation should include a comment explaining its purpose and prognosis. Bug: T240672 Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
* | http: Add missing documentation to class propertiesUmherirrender2024-09-141-0/+3
|/ | | | | | | | | | 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
* Use the instanceof and ::class features instead of stringsthiemowmde2024-02-021-5/+3
| | | | | | | | | | This makes it much easier for IDEs and tools like Phan to understand what's going on. Note this syntax is perfectly valid even if a class is undefined. Language features like `use`, `instanceof`, and `class_exists` work perfectly fine. We do this a lot in existing code. Change-Id: I4d397621ebcc6a7e842150f7641c1b23d082b730
* 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: Log GuzzleHttpRequest requestsGergő Tisza2023-02-081-3/+13
| | | | | | | | | | | | | | MwHttpRequest has a logger option, but GuzzleHttpRequest ignored it; fix that. This will log something like [2023-02-08T06:50:29+00:00] GET http://127.0.0.1:22100/ HTTP/1.1 - 301 NULL to the http channel, at level INFO on successful and at level ERROR on failed requests. Change-Id: I2e4067c67aace434ed111a1a09f03888ea43e924
* Remove old HTTP request implementationsPetr Pchelko2021-11-081-9/+8
| | | | | | | | | Since 1.34 setting non-default HTTP engine has been deprecated. It's time to remove the old implementations. Only Guzzle is now available. Change-Id: I978b75827e69db02cbc027fe0b89a028adfc6820
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Fix GuzzleHttpRequest request headersTim Starling2020-09-211-4/+6
| | | | | | | | | | | The headers passed to Guzzle via the Client constructor are termed "conditional", meaning that headers in the Request override them. If you set a "body" option containing a MultipartStream, it sets a default Content-Type request header, overriding the one from the Client constructor. So to send a multipart stream with a custom Content-Type, it is necessary to pass headers to Guzzle in the Request object. Change-Id: Ie7bfc548ce4211fbf3ec67e3913bbdd3482977c3
* Updating guzzlehttp/guzzle (6.5.5 => 7.0.1)Reedy2020-09-181-1/+0
| | | | | Change-Id: I02bdd522844c5174892bc8ead40b8f3dd550c624 Depends-On: I2968abb84303737233d99249f57e212675013f4e
* Respect configured default HTTP timeouts, and introduce max timeoutsTim Starling2020-05-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Support cookies in GuzzleHttpRequestEdward Chernenko2020-03-181-3/+29
| | | | | | | | | | | | | | | | | | Currently GuzzleHttpRequest is not sending any cookies. Furthermore, Guzzle expects its own format of CookieJar, which is not compatible with CookieJar used by MediaWiki. Solution is to add Guzzle Middleware that would obtain Cookie header from MediaWiki CookieJar and add it to outgoing Guzzle requests. Note: special handling of received cookies (Set-Cookie header from the server) is unnecessary, this is not Guzzle-specific code and is already done in MWHttpRequest::parseCookies(). Still, adding both a test of sending cookies and receiving cookies. Bug: T245644 Change-Id: If69840e65d5671989cf15450964da3c691fd164a
* build: Upgrade mediawiki-phan-config to 0.9.2Daimona Eaytoy2020-02-211-0/+1
| | | | | Bug: T244633 Change-Id: If8f35eaf3f2272717d7f12b4068d811b1a23d540
* Mimic CURLOPT_POST in GuzzleHttpRequestMoritz Schubotz (physikerwelt)2019-12-041-0/+4
| | | | | | | | | | | | | The MWHttpRequest is implemented by the CurlHttpRequest class and also the GuzzleHttpRequest class. However, curl based rendering set the CURLOPT_POST which implies that the 'Content-Type' header defaults to 'application/x-www-form-urlencoded'. To homgonize the functionality this patch mimics the curl behaviour in Guzzle. Bug: T232866 Change-Id: Id60a8de18e5f1e750a3bde23bd8b0deca4071165
* Unsuppress other phan issues (part 4)Daimona Eaytoy2019-08-311-0/+1
| | | | | | Bug: T231636 Depends-On: I58e67c2b38389df874438deada4239510d21654f Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
* Deprecate the Http classAryeh Gregor2019-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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-6/+53
| | | | | | | | | | 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
* Fix guzzle InvalidArgumentException when body is passed as an arrayBill Pirkle2018-12-121-1/+5
| | | | | | | | The postBody option to GuzzleHttpRequest can be passed as an array or as a string. We were previously handling the array case incorrectly. Bug: T211806 Change-Id: I8f40b9de9d40a9361eb45103608bf3aaa943bf73
* Create GuzzleHttpRequest class as new default for HttpRequestFactoryBill Pirkle2018-12-101-0/+202
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