-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Various cleanups after recent changes #58969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -117,11 +117,20 @@ public function getHeaders(bool $throw = true): array | |||
|
|||
public function getInfo(?string $type = null) | |||
{ | |||
if ('debug' === ($type ?? 'debug')) { | |||
$debug = implode('', array_column($this->info['previous_info'] ?? [], 'debug')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the debug info for AsyncResponse should contain all debug statements from previous requests, otherwise it's difficult to debug (happened to me)
@@ -291,6 +301,9 @@ public static function stream(iterable $responses, ?float $timeout = null, ?stri | |||
} | |||
} | |||
|
|||
if (null === $chunk) { | |||
throw new \LogicException(\sprintf('"%s" is not compliant with HttpClientInterface: its "stream()" method didn\'t yield any chunks when it should have.', get_debug_type($client))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can happen when a phpunit mock is used instead of a MockHttpClient
if (null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) { | ||
// Populate DNS cache for redirects if needed | ||
$port = $url['port'] ?? ('http' === $url['scheme'] ? 80 : 443); | ||
curl_setopt($ch, \CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CURLOPT_RESOLVE cannot be changed in the middle of a curl transaction so this is confusing dead code
}); | ||
|
||
return $previousHttpClient; | ||
return new MockHttpClient(new MockResponse($content, ['primary_ip' => $ipAddr])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpunit mocks...
// the DNS cache respectively | ||
'on_progress' => null, // callable(int $dlNow, int $dlSize, array $info) - throwing any exceptions MUST abort the | ||
// request; it MUST be called on connection, on headers and on completion; it SHOULD be | ||
// called on upload/download of data and at least 1/s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting to the previous (before the latest CVE) signature for the progress function: it's way more seamless to expose the resolve function as an implementation detail using the info array.
12adc67
to
f2efa4d
Compare
Failures on Windows are new to branch 5.4, I don't have them in v5.4.47 |
#58915 introduced the issue on Windows 🔍 |
6b415a1
to
c444d7c
Compare
c444d7c
to
01153f2
Compare
This PR was merged into the 7.2 branch. Discussion ---------- [HttpClient] fix amphp/http-client 5 support | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | following #58969 | License | MIT Commits ------- 06e56f8 fix amphp/http-client 5 support
Recent changes motivated by security issues made me deep dive into the code of HttpClient again.
Here are some cleanups I'd like to do on branch 5.4