bisect: advertise gzip,deflate encoding when supported#5434
bisect: advertise gzip,deflate encoding when supported#5434staabm wants to merge 9 commits intophpstan:2.1.xfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves download performance for bisect (and other HTTP fetches that reuse the same client setup) by advertising gzip,deflate support to allow servers to return compressed responses when PHP can decode them.
Changes:
- Added
PHPStan\Internal\HttpClientFactoryto create a Guzzle client and defaultAccept-Encoding: gzip,deflatewhenzlibis available. - Updated
BisectCommandto create its HTTP client via the new factory. - Updated
FixerApplicationto create its HTTP client via the new factory (and removed the directClientimport).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Internal/HttpClientFactory.php |
New factory that sets default Accept-Encoding and instantiates GuzzleHttp\Client. |
src/Command/FixerApplication.php |
Switches to using HttpClientFactory for download checks and removes direct client construction. |
src/Command/BisectCommand.php |
Switches to using HttpClientFactory for GitHub API requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Internal/HttpClientFactory.php
Outdated
| * | ||
| * @see \GuzzleHttp\RequestOptions | ||
| */ | ||
| public static function createClient(array $config): Client |
There was a problem hiding this comment.
Should be a service, not a static function. So we can pass options from config parameters
e3d22b8 to
4b03db7
Compare
| $client = new Client([ | ||
| RequestOptions::TIMEOUT => 30, | ||
| RequestOptions::CONNECT_TIMEOUT => 10, | ||
| $client = (new HttpClientFactory())->createClient([ |
There was a problem hiding this comment.
to make use of this service via DI in this command we would need to call CommandHelpe::begin, and this might require more changes.
I feel its not the right time todo this now. as this command is using cli options to pass it into a subshell, which CommandHelpe::begin seems to expect to be used for the main-process
time to fetch the commits..
... before this PR
... after this PR
-> saves ~10 seconds when downloading big responses