559 lines
18 KiB
C#
559 lines
18 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Net.Sockets;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
namespace System.Net
|
|
{
|
|
/// <summary>Provides connection management for HTTP connections.</summary>
|
|
// Token: 0x02000253 RID: 595
|
|
public class ServicePoint
|
|
{
|
|
// Token: 0x0600151A RID: 5402 RVA: 0x0004385C File Offset: 0x00041A5C
|
|
internal ServicePoint(global::System.Uri uri, int connectionLimit, int maxIdleTime)
|
|
{
|
|
this.uri = uri;
|
|
this.connectionLimit = connectionLimit;
|
|
this.maxIdleTime = maxIdleTime;
|
|
this.currentConnections = 0;
|
|
this.idleSince = DateTime.Now;
|
|
}
|
|
|
|
/// <summary>Gets the Uniform Resource Identifier (URI) of the server that this <see cref="T:System.Net.ServicePoint" /> object connects to.</summary>
|
|
/// <returns>An instance of the <see cref="T:System.Uri" /> class that contains the URI of the Internet server that this <see cref="T:System.Net.ServicePoint" /> object connects to.</returns>
|
|
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Net.ServicePoint" /> is in host mode.</exception>
|
|
// Token: 0x170006E1 RID: 1761
|
|
// (get) Token: 0x0600151B RID: 5403 RVA: 0x000438B4 File Offset: 0x00041AB4
|
|
public global::System.Uri Address
|
|
{
|
|
get
|
|
{
|
|
return this.uri;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600151C RID: 5404 RVA: 0x000438BC File Offset: 0x00041ABC
|
|
private static Exception GetMustImplement()
|
|
{
|
|
return new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>Specifies the delegate to associate a local <see cref="T:System.Net.IPEndPoint" /> with a <see cref="T:System.Net.ServicePoint" />.</summary>
|
|
/// <returns>A delegate that forces a <see cref="T:System.Net.ServicePoint" /> to use a particular local Internet Protocol (IP) address and port number. The default value is null.</returns>
|
|
// Token: 0x170006E2 RID: 1762
|
|
// (get) Token: 0x0600151D RID: 5405 RVA: 0x000438C4 File Offset: 0x00041AC4
|
|
// (set) Token: 0x0600151E RID: 5406 RVA: 0x000438CC File Offset: 0x00041ACC
|
|
public BindIPEndPoint BindIPEndPointDelegate
|
|
{
|
|
get
|
|
{
|
|
return this.endPointCallback;
|
|
}
|
|
set
|
|
{
|
|
this.endPointCallback = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the certificate received for this <see cref="T:System.Net.ServicePoint" /> object.</summary>
|
|
/// <returns>An instance of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> class that contains the security certificate received for this <see cref="T:System.Net.ServicePoint" /> object.</returns>
|
|
// Token: 0x170006E3 RID: 1763
|
|
// (get) Token: 0x0600151F RID: 5407 RVA: 0x000438D8 File Offset: 0x00041AD8
|
|
public X509Certificate Certificate
|
|
{
|
|
get
|
|
{
|
|
return this.certificate;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the last client certificate sent to the server.</summary>
|
|
/// <returns>An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object that contains the public values of the last client certificate sent to the server.</returns>
|
|
// Token: 0x170006E4 RID: 1764
|
|
// (get) Token: 0x06001520 RID: 5408 RVA: 0x000438E0 File Offset: 0x00041AE0
|
|
public X509Certificate ClientCertificate
|
|
{
|
|
get
|
|
{
|
|
return this.clientCertificate;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the number of milliseconds after which an active <see cref="T:System.Net.ServicePoint" /> connection is closed.</summary>
|
|
/// <returns>A <see cref="T:System.Int32" /> that specifies the number of milliseconds that an active <see cref="T:System.Net.ServicePoint" /> connection remains open. The default is -1, which allows an active <see cref="T:System.Net.ServicePoint" /> connection to stay connected indefinitely. Set this property to 0 to force <see cref="T:System.Net.ServicePoint" /> connections to close after servicing a request.</returns>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">The value specified for a set operation is a negative number less than -1.</exception>
|
|
// Token: 0x170006E5 RID: 1765
|
|
// (get) Token: 0x06001521 RID: 5409 RVA: 0x000438E8 File Offset: 0x00041AE8
|
|
// (set) Token: 0x06001522 RID: 5410 RVA: 0x000438F0 File Offset: 0x00041AF0
|
|
[global::System.MonoTODO]
|
|
public int ConnectionLeaseTimeout
|
|
{
|
|
get
|
|
{
|
|
throw ServicePoint.GetMustImplement();
|
|
}
|
|
set
|
|
{
|
|
throw ServicePoint.GetMustImplement();
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the maximum number of connections allowed on this <see cref="T:System.Net.ServicePoint" /> object.</summary>
|
|
/// <returns>The maximum number of connections allowed on this <see cref="T:System.Net.ServicePoint" /> object.</returns>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">The connection limit is equal to or less than 0. </exception>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
|
/// <IPermission class="System.Net.DnsPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
|
/// </PermissionSet>
|
|
// Token: 0x170006E6 RID: 1766
|
|
// (get) Token: 0x06001523 RID: 5411 RVA: 0x000438F8 File Offset: 0x00041AF8
|
|
// (set) Token: 0x06001524 RID: 5412 RVA: 0x00043900 File Offset: 0x00041B00
|
|
public int ConnectionLimit
|
|
{
|
|
get
|
|
{
|
|
return this.connectionLimit;
|
|
}
|
|
set
|
|
{
|
|
if (value <= 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
this.connectionLimit = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the connection name. </summary>
|
|
/// <returns>A <see cref="T:System.String" /> that represents the connection name. </returns>
|
|
// Token: 0x170006E7 RID: 1767
|
|
// (get) Token: 0x06001525 RID: 5413 RVA: 0x00043918 File Offset: 0x00041B18
|
|
public string ConnectionName
|
|
{
|
|
get
|
|
{
|
|
return this.uri.Scheme;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the number of open connections associated with this <see cref="T:System.Net.ServicePoint" /> object.</summary>
|
|
/// <returns>The number of open connections associated with this <see cref="T:System.Net.ServicePoint" /> object.</returns>
|
|
// Token: 0x170006E8 RID: 1768
|
|
// (get) Token: 0x06001526 RID: 5414 RVA: 0x00043928 File Offset: 0x00041B28
|
|
public int CurrentConnections
|
|
{
|
|
get
|
|
{
|
|
return this.currentConnections;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the date and time that the <see cref="T:System.Net.ServicePoint" /> object was last connected to a host.</summary>
|
|
/// <returns>A <see cref="T:System.DateTime" /> object that contains the date and time at which the <see cref="T:System.Net.ServicePoint" /> object was last connected.</returns>
|
|
// Token: 0x170006E9 RID: 1769
|
|
// (get) Token: 0x06001527 RID: 5415 RVA: 0x00043930 File Offset: 0x00041B30
|
|
// (set) Token: 0x06001528 RID: 5416 RVA: 0x00043938 File Offset: 0x00041B38
|
|
public DateTime IdleSince
|
|
{
|
|
get
|
|
{
|
|
return this.idleSince;
|
|
}
|
|
internal set
|
|
{
|
|
object obj = this.locker;
|
|
lock (obj)
|
|
{
|
|
this.idleSince = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the amount of time a connection associated with the <see cref="T:System.Net.ServicePoint" /> object can remain idle before the connection is closed.</summary>
|
|
/// <returns>The length of time, in milliseconds, that a connection associated with the <see cref="T:System.Net.ServicePoint" /> object can remain idle before it is closed and reused for another connection.</returns>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <see cref="P:System.Net.ServicePoint.MaxIdleTime" /> is set to less than <see cref="F:System.Threading.Timeout.Infinite" /> or greater than <see cref="F:System.Int32.MaxValue" />. </exception>
|
|
// Token: 0x170006EA RID: 1770
|
|
// (get) Token: 0x06001529 RID: 5417 RVA: 0x00043984 File Offset: 0x00041B84
|
|
// (set) Token: 0x0600152A RID: 5418 RVA: 0x0004398C File Offset: 0x00041B8C
|
|
public int MaxIdleTime
|
|
{
|
|
get
|
|
{
|
|
return this.maxIdleTime;
|
|
}
|
|
set
|
|
{
|
|
if (value < -1 || value > 2147483647)
|
|
{
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
this.maxIdleTime = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the version of the HTTP protocol that the <see cref="T:System.Net.ServicePoint" /> object uses.</summary>
|
|
/// <returns>A <see cref="T:System.Version" /> object that contains the HTTP protocol version that the <see cref="T:System.Net.ServicePoint" /> object uses.</returns>
|
|
// Token: 0x170006EB RID: 1771
|
|
// (get) Token: 0x0600152B RID: 5419 RVA: 0x000439B0 File Offset: 0x00041BB0
|
|
public virtual Version ProtocolVersion
|
|
{
|
|
get
|
|
{
|
|
return this.protocolVersion;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the size of the receiving buffer for the socket used by this <see cref="T:System.Net.ServicePoint" />.</summary>
|
|
/// <returns>A <see cref="T:System.Int32" /> that contains the size, in bytes, of the receive buffer. The default is 8192.</returns>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">The value specified for a set operation is greater than <see cref="F:System.Int32.MaxValue" />.</exception>
|
|
// Token: 0x170006EC RID: 1772
|
|
// (get) Token: 0x0600152C RID: 5420 RVA: 0x000439B8 File Offset: 0x00041BB8
|
|
// (set) Token: 0x0600152D RID: 5421 RVA: 0x000439C0 File Offset: 0x00041BC0
|
|
[global::System.MonoTODO]
|
|
public int ReceiveBufferSize
|
|
{
|
|
get
|
|
{
|
|
throw ServicePoint.GetMustImplement();
|
|
}
|
|
set
|
|
{
|
|
throw ServicePoint.GetMustImplement();
|
|
}
|
|
}
|
|
|
|
/// <summary>Indicates whether the <see cref="T:System.Net.ServicePoint" /> object supports pipelined connections.</summary>
|
|
/// <returns>true if the <see cref="T:System.Net.ServicePoint" /> object supports pipelined connections; otherwise, false.</returns>
|
|
// Token: 0x170006ED RID: 1773
|
|
// (get) Token: 0x0600152E RID: 5422 RVA: 0x000439C8 File Offset: 0x00041BC8
|
|
public bool SupportsPipelining
|
|
{
|
|
get
|
|
{
|
|
return HttpVersion.Version11.Equals(this.protocolVersion);
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets a <see cref="T:System.Boolean" /> value that determines whether 100-Continue behavior is used.</summary>
|
|
/// <returns>true to expect 100-Continue responses for POST requests; otherwise, false. The default value is true.</returns>
|
|
// Token: 0x170006EE RID: 1774
|
|
// (get) Token: 0x0600152F RID: 5423 RVA: 0x000439DC File Offset: 0x00041BDC
|
|
// (set) Token: 0x06001530 RID: 5424 RVA: 0x000439E4 File Offset: 0x00041BE4
|
|
public bool Expect100Continue
|
|
{
|
|
get
|
|
{
|
|
return this.SendContinue;
|
|
}
|
|
set
|
|
{
|
|
this.SendContinue = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets a <see cref="T:System.Boolean" /> value that determines whether the Nagle algorithm is used on connections managed by this <see cref="T:System.Net.ServicePoint" /> object.</summary>
|
|
/// <returns>true to use the Nagle algorithm; otherwise, false. The default value is true.</returns>
|
|
// Token: 0x170006EF RID: 1775
|
|
// (get) Token: 0x06001531 RID: 5425 RVA: 0x000439F0 File Offset: 0x00041BF0
|
|
// (set) Token: 0x06001532 RID: 5426 RVA: 0x000439F8 File Offset: 0x00041BF8
|
|
public bool UseNagleAlgorithm
|
|
{
|
|
get
|
|
{
|
|
return this.useNagle;
|
|
}
|
|
set
|
|
{
|
|
this.useNagle = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F0 RID: 1776
|
|
// (get) Token: 0x06001533 RID: 5427 RVA: 0x00043A04 File Offset: 0x00041C04
|
|
// (set) Token: 0x06001534 RID: 5428 RVA: 0x00043A44 File Offset: 0x00041C44
|
|
internal bool SendContinue
|
|
{
|
|
get
|
|
{
|
|
return this.sendContinue && (this.protocolVersion == null || this.protocolVersion == HttpVersion.Version11);
|
|
}
|
|
set
|
|
{
|
|
this.sendContinue = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F1 RID: 1777
|
|
// (get) Token: 0x06001535 RID: 5429 RVA: 0x00043A50 File Offset: 0x00041C50
|
|
// (set) Token: 0x06001536 RID: 5430 RVA: 0x00043A58 File Offset: 0x00041C58
|
|
internal bool UsesProxy
|
|
{
|
|
get
|
|
{
|
|
return this.usesProxy;
|
|
}
|
|
set
|
|
{
|
|
this.usesProxy = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F2 RID: 1778
|
|
// (get) Token: 0x06001537 RID: 5431 RVA: 0x00043A64 File Offset: 0x00041C64
|
|
// (set) Token: 0x06001538 RID: 5432 RVA: 0x00043A6C File Offset: 0x00041C6C
|
|
internal bool UseConnect
|
|
{
|
|
get
|
|
{
|
|
return this.useConnect;
|
|
}
|
|
set
|
|
{
|
|
this.useConnect = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F3 RID: 1779
|
|
// (get) Token: 0x06001539 RID: 5433 RVA: 0x00043A78 File Offset: 0x00041C78
|
|
internal bool AvailableForRecycling
|
|
{
|
|
get
|
|
{
|
|
return this.CurrentConnections == 0 && this.maxIdleTime != -1 && DateTime.Now >= this.IdleSince.AddMilliseconds((double)this.maxIdleTime);
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F4 RID: 1780
|
|
// (get) Token: 0x0600153A RID: 5434 RVA: 0x00043AC0 File Offset: 0x00041CC0
|
|
internal Hashtable Groups
|
|
{
|
|
get
|
|
{
|
|
if (this.groups == null)
|
|
{
|
|
this.groups = new Hashtable();
|
|
}
|
|
return this.groups;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006F5 RID: 1781
|
|
// (get) Token: 0x0600153B RID: 5435 RVA: 0x00043AE0 File Offset: 0x00041CE0
|
|
internal IPHostEntry HostEntry
|
|
{
|
|
get
|
|
{
|
|
object obj = this.hostE;
|
|
lock (obj)
|
|
{
|
|
if (this.host != null)
|
|
{
|
|
return this.host;
|
|
}
|
|
string text = this.uri.Host;
|
|
if (this.uri.HostNameType == global::System.UriHostNameType.IPv6 || this.uri.HostNameType == global::System.UriHostNameType.IPv4)
|
|
{
|
|
if (this.uri.HostNameType == global::System.UriHostNameType.IPv6)
|
|
{
|
|
text = text.Substring(1, text.Length - 2);
|
|
}
|
|
this.host = new IPHostEntry();
|
|
this.host.AddressList = new IPAddress[] { IPAddress.Parse(text) };
|
|
return this.host;
|
|
}
|
|
try
|
|
{
|
|
this.host = Dns.GetHostByName(text);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
return this.host;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600153C RID: 5436 RVA: 0x00043BF8 File Offset: 0x00041DF8
|
|
internal void SetVersion(Version version)
|
|
{
|
|
this.protocolVersion = version;
|
|
}
|
|
|
|
// Token: 0x0600153D RID: 5437 RVA: 0x00043C04 File Offset: 0x00041E04
|
|
private WebConnectionGroup GetConnectionGroup(string name)
|
|
{
|
|
if (name == null)
|
|
{
|
|
name = string.Empty;
|
|
}
|
|
WebConnectionGroup webConnectionGroup = this.Groups[name] as WebConnectionGroup;
|
|
if (webConnectionGroup != null)
|
|
{
|
|
return webConnectionGroup;
|
|
}
|
|
webConnectionGroup = new WebConnectionGroup(this, name);
|
|
this.Groups[name] = webConnectionGroup;
|
|
return webConnectionGroup;
|
|
}
|
|
|
|
// Token: 0x0600153E RID: 5438 RVA: 0x00043C50 File Offset: 0x00041E50
|
|
internal EventHandler SendRequest(HttpWebRequest request, string groupName)
|
|
{
|
|
object obj = this.locker;
|
|
WebConnection connection;
|
|
lock (obj)
|
|
{
|
|
WebConnectionGroup connectionGroup = this.GetConnectionGroup(groupName);
|
|
connection = connectionGroup.GetConnection(request);
|
|
}
|
|
return connection.SendRequest(request);
|
|
}
|
|
|
|
/// <summary>Removes the specified connection group from this <see cref="T:System.Net.ServicePoint" /> object.</summary>
|
|
/// <returns>A <see cref="T:System.Boolean" /> value that indicates whether the connection group was closed.</returns>
|
|
/// <param name="connectionGroupName">The name of the connection group that contains the connections to close and remove from this service point. </param>
|
|
// Token: 0x0600153F RID: 5439 RVA: 0x00043CAC File Offset: 0x00041EAC
|
|
public bool CloseConnectionGroup(string connectionGroupName)
|
|
{
|
|
object obj = this.locker;
|
|
lock (obj)
|
|
{
|
|
WebConnectionGroup connectionGroup = this.GetConnectionGroup(connectionGroupName);
|
|
if (connectionGroup != null)
|
|
{
|
|
connectionGroup.Close();
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x06001540 RID: 5440 RVA: 0x00043D0C File Offset: 0x00041F0C
|
|
internal void IncrementConnection()
|
|
{
|
|
object obj = this.locker;
|
|
lock (obj)
|
|
{
|
|
this.currentConnections++;
|
|
this.idleSince = DateTime.Now.AddMilliseconds(1000000.0);
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001541 RID: 5441 RVA: 0x00043D78 File Offset: 0x00041F78
|
|
internal void DecrementConnection()
|
|
{
|
|
object obj = this.locker;
|
|
lock (obj)
|
|
{
|
|
this.currentConnections--;
|
|
if (this.currentConnections == 0)
|
|
{
|
|
this.idleSince = DateTime.Now;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001542 RID: 5442 RVA: 0x00043DE0 File Offset: 0x00041FE0
|
|
internal void SetCertificates(X509Certificate client, X509Certificate server)
|
|
{
|
|
this.certificate = server;
|
|
this.clientCertificate = client;
|
|
}
|
|
|
|
// Token: 0x06001543 RID: 5443 RVA: 0x00043DF0 File Offset: 0x00041FF0
|
|
internal bool CallEndPointDelegate(global::System.Net.Sockets.Socket sock, IPEndPoint remote)
|
|
{
|
|
if (this.endPointCallback == null)
|
|
{
|
|
return true;
|
|
}
|
|
int num = 0;
|
|
checked
|
|
{
|
|
for (;;)
|
|
{
|
|
IPEndPoint ipendPoint = null;
|
|
try
|
|
{
|
|
ipendPoint = this.endPointCallback(this, remote, num);
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
if (ipendPoint == null)
|
|
{
|
|
break;
|
|
}
|
|
try
|
|
{
|
|
sock.Bind(ipendPoint);
|
|
}
|
|
catch (global::System.Net.Sockets.SocketException)
|
|
{
|
|
num++;
|
|
continue;
|
|
}
|
|
return true;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Token: 0x040011AE RID: 4526
|
|
private global::System.Uri uri;
|
|
|
|
// Token: 0x040011AF RID: 4527
|
|
private int connectionLimit;
|
|
|
|
// Token: 0x040011B0 RID: 4528
|
|
private int maxIdleTime;
|
|
|
|
// Token: 0x040011B1 RID: 4529
|
|
private int currentConnections;
|
|
|
|
// Token: 0x040011B2 RID: 4530
|
|
private DateTime idleSince;
|
|
|
|
// Token: 0x040011B3 RID: 4531
|
|
private Version protocolVersion;
|
|
|
|
// Token: 0x040011B4 RID: 4532
|
|
private X509Certificate certificate;
|
|
|
|
// Token: 0x040011B5 RID: 4533
|
|
private X509Certificate clientCertificate;
|
|
|
|
// Token: 0x040011B6 RID: 4534
|
|
private IPHostEntry host;
|
|
|
|
// Token: 0x040011B7 RID: 4535
|
|
private bool usesProxy;
|
|
|
|
// Token: 0x040011B8 RID: 4536
|
|
private Hashtable groups;
|
|
|
|
// Token: 0x040011B9 RID: 4537
|
|
private bool sendContinue = true;
|
|
|
|
// Token: 0x040011BA RID: 4538
|
|
private bool useConnect;
|
|
|
|
// Token: 0x040011BB RID: 4539
|
|
private object locker = new object();
|
|
|
|
// Token: 0x040011BC RID: 4540
|
|
private object hostE = new object();
|
|
|
|
// Token: 0x040011BD RID: 4541
|
|
private bool useNagle;
|
|
|
|
// Token: 0x040011BE RID: 4542
|
|
private BindIPEndPoint endPointCallback;
|
|
}
|
|
}
|