private function generateAuthorityFromUri(Uri $uri)
{
$scheme = $uri->getScheme();
$host = $uri->getHost();
$port = $uri->getPort();
if (empty($port)) {
$port = $scheme === 'https' ? 443 : 80;
}
return "{$host}:{$port}";
}