private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
{
if (proxy != null && !address.IsLoopback)
{
Uri proxyAddress = proxy.GetProxy(address);
if (proxyAddress != null)
{
if (proxyAddress.Scheme != Uri.UriSchemeHttp)
{
throw new NotSupportedException(SR.Format(SR.net_proxyschemenotsupported, address.Scheme));
}
address = proxyAddress;
return true;
}
}
return false;
}