Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ServicePointManager.cs
Go to the documentation of this file.
5
6namespace System.Net;
7
9{
11
13
15
17
18 private static int s_connectionLimit = 2;
19
20 private static int s_maxServicePoints;
21
22 private static int s_maxServicePointIdleTime = 100000;
23
24 private static int s_dnsRefreshTimeout = 120000;
25
27 {
28 get
29 {
31 }
32 set
33 {
36 }
37 }
38
39 public static int MaxServicePoints
40 {
41 get
42 {
43 return s_maxServicePoints;
44 }
45 set
46 {
47 if (value < 0)
48 {
49 throw new ArgumentOutOfRangeException("value");
50 }
52 }
53 }
54
55 public static int DefaultConnectionLimit
56 {
57 get
58 {
59 return s_connectionLimit;
60 }
61 set
62 {
63 if (value <= 0)
64 {
65 throw new ArgumentOutOfRangeException("value");
66 }
68 }
69 }
70
71 public static int MaxServicePointIdleTime
72 {
73 get
74 {
76 }
77 set
78 {
79 if (value < -1)
80 {
81 throw new ArgumentOutOfRangeException("value");
82 }
84 }
85 }
86
87 public static bool UseNagleAlgorithm { get; set; } = true;
88
89
90 public static bool Expect100Continue { get; set; } = true;
91
92
93 public static bool EnableDnsRoundRobin { get; set; }
94
95 public static int DnsRefreshTimeout
96 {
97 get
98 {
100 }
101 set
102 {
104 }
105 }
106
107 public static RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get; set; }
108
109 public static bool ReusePort { get; set; }
110
111 public static bool CheckCertificateRevocationList { get; set; }
112
113 [UnsupportedOSPlatform("browser")]
114 public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption;
115
116
118 {
119 if (((uint)value & 0xFFFFC03Fu) != 0)
120 {
122 }
123 }
124
125 [Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
126 public static ServicePoint FindServicePoint(Uri address)
127 {
128 return FindServicePoint(address, null);
129 }
130
131 [Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
132 public static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy)
133 {
134 return FindServicePoint(new Uri(uriString), proxy);
135 }
136
137 [Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
139 {
140 if (address == null)
141 {
142 throw new ArgumentNullException("address");
143 }
144 bool isProxy = ProxyAddressIfNecessary(ref address, proxy);
145 string key = MakeQueryString(address, isProxy);
147 ServicePoint target;
148 while (!s_servicePointTable.TryGetValue(key, out value) || !value.TryGetTarget(out target))
149 {
151 {
152 if (!item.Value.TryGetTarget(out var _))
153 {
154 s_servicePointTable.TryRemove(item);
155 }
156 }
157 target = new ServicePoint(address)
158 {
159 ConnectionLimit = DefaultConnectionLimit,
160 IdleSince = DateTime.Now,
163 };
165 }
166 target.IdleSince = DateTime.Now;
167 return target;
168 }
169
170 private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
171 {
172 if (proxy != null && !address.IsLoopback)
173 {
174 try
175 {
176 Uri proxy2 = proxy.GetProxy(address);
177 if (proxy2 != null)
178 {
179 if (proxy2.Scheme != Uri.UriSchemeHttp)
180 {
182 }
183 address = proxy2;
184 return true;
185 }
186 }
188 {
189 }
190 }
191 return false;
192 }
193
194 private static string MakeQueryString(Uri address)
195 {
196 if (!address.IsDefaultPort)
197 {
198 return address.Scheme + "://" + address.DnsSafeHost + ":" + address.Port;
199 }
200 return address.Scheme + "://" + address.DnsSafeHost;
201 }
202
203 private static string MakeQueryString(Uri address, bool isProxy)
204 {
205 string text = MakeQueryString(address);
206 if (!isProxy)
207 {
208 return text;
209 }
210 return text + "://proxy";
211 }
212
213 public static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval)
214 {
215 if (enabled)
216 {
217 if (keepAliveTime <= 0)
218 {
219 throw new ArgumentOutOfRangeException("keepAliveTime");
220 }
221 if (keepAliveInterval <= 0)
222 {
223 throw new ArgumentOutOfRangeException("keepAliveInterval");
224 }
225 }
226 }
227}
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static string MakeQueryString(Uri address)
static readonly ConcurrentDictionary< string, WeakReference< ServicePoint > > s_servicePointTable
static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval)
static ServicePoint FindServicePoint(Uri address, IWebProxy? proxy)
static SecurityProtocolType s_securityProtocolType
static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy proxy)
static ? RemoteCertificateValidationCallback ServerCertificateValidationCallback
static void ValidateSecurityProtocol(SecurityProtocolType value)
static string MakeQueryString(Uri address, bool isProxy)
static SecurityProtocolType SecurityProtocol
static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy)
static ServicePoint FindServicePoint(Uri address)
static string net_securityprotocolnotsupported
Definition SR.cs:16
static string net_proxyschemenotsupported
Definition SR.cs:14
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
string DnsSafeHost
Definition Uri.cs:519
bool IsDefaultPort
Definition Uri.cs:333
static readonly string UriSchemeHttp
Definition Uri.cs:165
int Port
Definition Uri.cs:453
static DateTime Now
Definition DateTime.cs:103