Imported Upstream version 4.4.0.40

Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
Xamarin Public Jenkins
2016-03-16 12:38:19 -04:00
parent f3e3aab35a
commit a632333cc7
110 changed files with 1496 additions and 556 deletions

View File

@@ -593,6 +593,7 @@ namespace System.Net
CheckRequestStarted ();
proxy = value;
servicePoint = null; // we may need a new one
GetServicePoint ();
}
}
@@ -969,11 +970,17 @@ namespace System.Net
}
}
if (!requestSent) {
if (requestSent)
return;
try {
requestSent = true;
redirects = 0;
servicePoint = GetServicePoint ();
abortHandler = servicePoint.SendRequest (this, connectionGroup);
} catch (Exception ex) {
aread.SetCompleted (synch, ex);
aread.DoCallback ();
}
});

View File

@@ -49,8 +49,6 @@ namespace System.Net
DateTime idleSince;
DateTime lastDnsResolve;
Version protocolVersion;
X509Certificate certificate;
X509Certificate clientCertificate;
IPHostEntry host;
bool usesProxy;
Dictionary<string,WebConnectionGroup> groups;
@@ -92,14 +90,6 @@ namespace System.Net
set { endPointCallback = value; }
}
public X509Certificate Certificate {
get { return certificate; }
}
public X509Certificate ClientCertificate {
get { return clientCertificate; }
}
[MonoTODO]
public int ConnectionLeaseTimeout
{
@@ -413,20 +403,55 @@ namespace System.Net
return false;
}
internal void SetServerCertificate (X509Certificate server)
//
// Copied from the referencesource
//
object m_ServerCertificateOrBytes;
object m_ClientCertificateOrBytes;
/// <devdoc>
/// <para>
/// Gets the certificate received for this <see cref='System.Net.ServicePoint'/>.
/// </para>
/// </devdoc>
public X509Certificate Certificate {
get {
object chkCert = m_ServerCertificateOrBytes;
if (chkCert != null && chkCert.GetType() == typeof(byte[]))
return (X509Certificate)(m_ServerCertificateOrBytes = new X509Certificate((byte[]) chkCert));
else
return chkCert as X509Certificate;
}
}
internal void UpdateServerCertificate(X509Certificate certificate)
{
var cloned = server != null ? new X509Certificate (server) : null;
var old = Interlocked.Exchange (ref certificate, cloned);
if (old != null)
old.Dispose ();
if (certificate != null)
m_ServerCertificateOrBytes = certificate.GetRawCertData();
else
m_ServerCertificateOrBytes = null;
}
internal void SetClientCertificate (X509Certificate clientCertificate)
/// <devdoc>
/// <para>
/// Gets the Client Certificate sent by us to the Server.
/// </para>
/// </devdoc>
public X509Certificate ClientCertificate {
get {
object chkCert = m_ClientCertificateOrBytes;
if (chkCert != null && chkCert.GetType() == typeof(byte[]))
return (X509Certificate)(m_ClientCertificateOrBytes = new X509Certificate((byte[]) chkCert));
else
return chkCert as X509Certificate;
}
}
internal void UpdateClientCertificate(X509Certificate certificate)
{
var cloned = clientCertificate != null ? new X509Certificate (clientCertificate) : null;
var old = Interlocked.Exchange (ref clientCertificate, cloned);
if (old != null)
old.Dispose ();
if (certificate != null)
m_ClientCertificateOrBytes = certificate.GetRawCertData();
else
m_ClientCertificateOrBytes = null;
}
internal bool CallEndPointDelegate (Socket sock, IPEndPoint remote)

View File

@@ -114,7 +114,7 @@ namespace System.Net
// Static properties
private static ICertificatePolicy policy = new DefaultCertificatePolicy ();
private static ICertificatePolicy policy;
private static int defaultConnectionLimit = DefaultPersistentConnectionLimit;
private static int maxServicePointIdleTime = 100000; // 100 seconds
private static int maxServicePoints = 0;
@@ -174,7 +174,11 @@ namespace System.Net
[Obsolete ("Use ServerCertificateValidationCallback instead", false)]
public static ICertificatePolicy CertificatePolicy {
get { return policy; }
get {
if (policy == null)
Interlocked.CompareExchange (ref policy, new DefaultCertificatePolicy (), null);
return policy;
}
set { policy = value; }
}
@@ -328,7 +332,7 @@ namespace System.Net
usesProxy = true;
bool isSecure = address.Scheme == "https";
address = proxy.GetProxy (address);
if (address.Scheme != "http" && !isSecure)
if (address.Scheme != "http")
throw new NotSupportedException ("Proxy scheme not supported.");
if (isSecure && address.Scheme == "http")

View File

@@ -419,6 +419,7 @@ namespace System.Net
status = tlsStream.ExceptionStatus;
else if (!request.Aborted)
status = WebExceptionStatus.ConnectFailure;
connect_exception = ex;
return false;
}
@@ -992,9 +993,6 @@ namespace System.Net
internal bool EndWrite (HttpWebRequest request, bool throwOnError, IAsyncResult result)
{
if (request.FinishedReading)
return true;
Stream s = null;
lock (this) {
if (status == WebExceptionStatus.RequestCanceled)