Update website
This commit is contained in:
parent
0a686aeb9a
commit
c4ffa0f6ee
4360 changed files with 1727 additions and 718385 deletions
33
vendor/symfony/http-client/NativeHttpClient.php
vendored
33
vendor/symfony/http-client/NativeHttpClient.php
vendored
|
@ -79,6 +79,9 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
if (str_starts_with($options['bindto'], 'host!')) {
|
||||
$options['bindto'] = substr($options['bindto'], 5);
|
||||
}
|
||||
if ((\PHP_VERSION_ID < 80223 || 80300 <= \PHP_VERSION_ID && 80311 < \PHP_VERSION_ID) && '\\' === \DIRECTORY_SEPARATOR && '[' === $options['bindto'][0]) {
|
||||
$options['bindto'] = preg_replace('{^\[[^\]]++\]}', '[$0]', $options['bindto']);
|
||||
}
|
||||
}
|
||||
|
||||
$hasContentLength = isset($options['normalized_headers']['content-length']);
|
||||
|
@ -138,15 +141,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
// Memoize the last progress to ease calling the callback periodically when no network transfer happens
|
||||
$lastProgress = [0, 0];
|
||||
$maxDuration = 0 < $options['max_duration'] ? $options['max_duration'] : \INF;
|
||||
$multi = $this->multi;
|
||||
$resolve = static function (string $host, ?string $ip = null) use ($multi): ?string {
|
||||
if (null !== $ip) {
|
||||
$multi->dnsCache[$host] = $ip;
|
||||
}
|
||||
|
||||
return $multi->dnsCache[$host] ?? null;
|
||||
};
|
||||
$onProgress = static function (...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration, $resolve) {
|
||||
$onProgress = static function (...$progress) use ($onProgress, &$lastProgress, &$info, $maxDuration) {
|
||||
if ($info['total_time'] >= $maxDuration) {
|
||||
throw new TransportException(sprintf('Max duration was reached for "%s".', implode('', $info['url'])));
|
||||
}
|
||||
|
@ -162,7 +157,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
$lastProgress = $progress ?: $lastProgress;
|
||||
}
|
||||
|
||||
$onProgress($lastProgress[0], $lastProgress[1], $progressInfo, $resolve);
|
||||
$onProgress($lastProgress[0], $lastProgress[1], $progressInfo);
|
||||
};
|
||||
} elseif (0 < $options['max_duration']) {
|
||||
$maxDuration = $options['max_duration'];
|
||||
|
@ -330,7 +325,12 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
*/
|
||||
private static function dnsResolve($host, NativeClientState $multi, array &$info, ?\Closure $onProgress): string
|
||||
{
|
||||
if (null === $ip = $multi->dnsCache[$host] ?? null) {
|
||||
$flag = '' !== $host && '[' === $host[0] && ']' === $host[-1] && str_contains($host, ':') ? \FILTER_FLAG_IPV6 : \FILTER_FLAG_IPV4;
|
||||
$ip = \FILTER_FLAG_IPV6 === $flag ? substr($host, 1, -1) : $host;
|
||||
|
||||
if (filter_var($ip, \FILTER_VALIDATE_IP, $flag)) {
|
||||
// The host is already an IP address
|
||||
} elseif (null === $ip = $multi->dnsCache[$host] ?? null) {
|
||||
$info['debug'] .= "* Hostname was NOT found in DNS cache\n";
|
||||
$now = microtime(true);
|
||||
|
||||
|
@ -338,13 +338,15 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
throw new TransportException(sprintf('Could not resolve host "%s".', $host));
|
||||
}
|
||||
|
||||
$info['namelookup_time'] = microtime(true) - ($info['start_time'] ?: $now);
|
||||
$multi->dnsCache[$host] = $ip = $ip[0];
|
||||
$info['debug'] .= "* Added {$host}:0:{$ip} to DNS cache\n";
|
||||
$host = $ip;
|
||||
} else {
|
||||
$info['debug'] .= "* Hostname was found in DNS cache\n";
|
||||
$host = str_contains($ip, ':') ? "[$ip]" : $ip;
|
||||
}
|
||||
|
||||
$info['namelookup_time'] = microtime(true) - ($info['start_time'] ?: $now);
|
||||
$info['primary_ip'] = $ip;
|
||||
|
||||
if ($onProgress) {
|
||||
|
@ -352,7 +354,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
$onProgress();
|
||||
}
|
||||
|
||||
return $ip;
|
||||
return $host;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,13 +385,14 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
|
||||
try {
|
||||
$url = self::parseUrl($location);
|
||||
$locationHasHost = isset($url['authority']);
|
||||
$url = self::resolveUrl($url, $info['url']);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$info['redirect_url'] = null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = self::resolveUrl($url, $info['url']);
|
||||
$info['redirect_url'] = implode('', $url);
|
||||
|
||||
if ($info['redirect_count'] >= $maxRedirects) {
|
||||
|
@ -424,7 +427,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
|
|||
|
||||
[$host, $port] = self::parseHostPort($url, $info);
|
||||
|
||||
if (false !== (parse_url($location.'#', \PHP_URL_HOST) ?? false)) {
|
||||
if ($locationHasHost) {
|
||||
// Authorization and Cookie headers MUST NOT follow except for the initial host name
|
||||
$requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
|
||||
$requestHeaders[] = 'Host: '.$host.$port;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue