Imported Upstream version 4.4.1.0

Former-commit-id: 83cefab0c44461cb78f9e4aa51ca6235525b0df6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-06-22 10:54:06 +00:00
parent 180e8b1935
commit 589d484eee
28 changed files with 48 additions and 50 deletions

View File

@ -42,7 +42,7 @@ namespace System.Net
{
public class ServicePoint
{
Uri uri;
readonly Uri uri;
int connectionLimit;
int maxIdleTime;
int currentConnections;
@ -345,15 +345,31 @@ namespace System.Net
lock (hostE) {
string uriHost = uri.Host;
if (host == null || HasTimedOut) {
lastDnsResolve = DateTime.UtcNow;
if (host == null) {
// Cannot do DNS resolution on literal IP addresses
if (uri.HostNameType == UriHostNameType.IPv6 || uri.HostNameType == UriHostNameType.IPv4) {
try {
host = Dns.GetHostEntry (uriHost);
}
catch (Exception) {
return null;
if (uri.HostNameType == UriHostNameType.IPv6) {
// Remove square brackets
uriHost = uriHost.Substring (1, uriHost.Length - 2);
}
// Creates IPHostEntry
host = new IPHostEntry();
host.AddressList = new IPAddress[] { IPAddress.Parse (uriHost) };
return host;
}
} else {
if (!HasTimedOut)
return host;
}
lastDnsResolve = DateTime.UtcNow;
try {
host = Dns.GetHostEntry (uriHost);
} catch {
return null;
}
}