Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SocketsHttpHandler.cs
Go to the documentation of this file.
4using System.IO;
9
10namespace System.Net.Http;
11
12[UnsupportedOSPlatform("browser")]
14{
16
18
19 private bool _disposed;
20
22 public static bool IsSupported => !OperatingSystem.IsBrowser();
23
24 public bool UseCookies
25 {
26 get
27 {
29 }
30 set
31 {
33 _settings._useCookies = value;
34 }
35 }
36
38 {
39 get
40 {
41 return _settings._cookieContainer ?? (_settings._cookieContainer = new CookieContainer());
42 }
44 set
45 {
47 _settings._cookieContainer = value;
48 }
49 }
50
52 {
53 get
54 {
56 }
57 set
58 {
60 _settings._automaticDecompression = value;
61 }
62 }
63
64 public bool UseProxy
65 {
66 get
67 {
68 return _settings._useProxy;
69 }
70 set
71 {
73 _settings._useProxy = value;
74 }
75 }
76
78 {
79 get
80 {
81 return _settings._proxy;
82 }
83 set
84 {
86 _settings._proxy = value;
87 }
88 }
89
91 {
92 get
93 {
95 }
96 set
97 {
99 _settings._defaultProxyCredentials = value;
100 }
101 }
102
103 public bool PreAuthenticate
104 {
105 get
106 {
108 }
109 set
110 {
112 _settings._preAuthenticate = value;
113 }
114 }
115
117 {
118 get
119 {
120 return _settings._credentials;
121 }
122 set
123 {
125 _settings._credentials = value;
126 }
127 }
128
130 {
131 get
132 {
134 }
135 set
136 {
138 _settings._allowAutoRedirect = value;
139 }
140 }
141
143 {
144 get
145 {
147 }
148 set
149 {
150 if (value <= 0)
151 {
153 }
155 _settings._maxAutomaticRedirections = value;
156 }
157 }
158
160 {
161 get
162 {
164 }
165 set
166 {
167 if (value < 1)
168 {
170 }
172 _settings._maxConnectionsPerServer = value;
173 }
174 }
175
177 {
178 get
179 {
181 }
182 set
183 {
184 if (value < 0)
185 {
187 }
189 _settings._maxResponseDrainSize = value;
190 }
191 }
192
194 {
195 get
196 {
198 }
199 set
200 {
201 if ((value < TimeSpan.Zero && value != Timeout.InfiniteTimeSpan) || value.TotalMilliseconds > 2147483647.0)
202 {
203 throw new ArgumentOutOfRangeException("value");
204 }
206 _settings._maxResponseDrainTime = value;
207 }
208 }
209
211 {
212 get
213 {
215 }
216 set
217 {
218 if (value <= 0)
219 {
221 }
223 _settings._maxResponseHeadersLength = value;
224 }
225 }
226
228 {
229 get
230 {
231 return _settings._sslOptions ?? (_settings._sslOptions = new SslClientAuthenticationOptions());
232 }
234 set
235 {
237 _settings._sslOptions = value;
238 }
239 }
240
242 {
243 get
244 {
246 }
247 set
248 {
250 {
251 throw new ArgumentOutOfRangeException("value");
252 }
254 _settings._pooledConnectionLifetime = value;
255 }
256 }
257
259 {
260 get
261 {
263 }
264 set
265 {
267 {
268 throw new ArgumentOutOfRangeException("value");
269 }
271 _settings._pooledConnectionIdleTimeout = value;
272 }
273 }
274
276 {
277 get
278 {
280 }
281 set
282 {
283 if ((value <= TimeSpan.Zero && value != Timeout.InfiniteTimeSpan) || value.TotalMilliseconds > 2147483647.0)
284 {
285 throw new ArgumentOutOfRangeException("value");
286 }
288 _settings._connectTimeout = value;
289 }
290 }
291
293 {
294 get
295 {
297 }
298 set
299 {
300 if ((value < TimeSpan.Zero && value != Timeout.InfiniteTimeSpan) || value.TotalMilliseconds > 2147483647.0)
301 {
302 throw new ArgumentOutOfRangeException("value");
303 }
305 _settings._expect100ContinueTimeout = value;
306 }
307 }
308
310 {
311 get
312 {
314 }
315 set
316 {
318 {
320 throw new ArgumentOutOfRangeException("InitialHttp2StreamWindowSize", message);
321 }
323 _settings._initialHttp2StreamWindowSize = value;
324 }
325 }
326
328 {
329 get
330 {
332 }
333 set
334 {
335 if (value.Ticks < 10000000 && value != Timeout.InfiniteTimeSpan)
336 {
338 }
340 _settings._keepAlivePingDelay = value;
341 }
342 }
343
345 {
346 get
347 {
349 }
350 set
351 {
352 if (value.Ticks < 10000000 && value != Timeout.InfiniteTimeSpan)
353 {
355 }
357 _settings._keepAlivePingTimeout = value;
358 }
359 }
360
362 {
363 get
364 {
366 }
367 set
368 {
370 _settings._keepAlivePingPolicy = value;
371 }
372 }
373
375 {
376 get
377 {
379 }
380 set
381 {
383 _settings._enableMultipleHttp2Connections = value;
384 }
385 }
386
388 {
389 get
390 {
392 }
393 set
394 {
396 _settings._connectCallback = value;
397 }
398 }
399
401 {
402 get
403 {
405 }
406 set
407 {
409 _settings._plaintextStreamFilter = value;
410 }
411 }
412
413 public IDictionary<string, object?> Properties => _settings._properties ?? (_settings._properties = new Dictionary<string, object>());
414
416 {
417 get
418 {
420 }
421 set
422 {
424 _settings._requestHeaderEncodingSelector = value;
425 }
426 }
427
429 {
430 get
431 {
433 }
434 set
435 {
437 _settings._responseHeaderEncodingSelector = value;
438 }
439 }
440
441 [CLSCompliant(false)]
443 {
444 get
445 {
447 }
448 set
449 {
451 _settings._activityHeadersPropagator = value;
452 }
453 }
454
455 private void CheckDisposed()
456 {
457 if (_disposed)
458 {
459 throw new ObjectDisposedException("SocketsHttpHandler");
460 }
461 }
462
464 {
466 if (_handler != null)
467 {
469 }
470 }
471
472 protected override void Dispose(bool disposing)
473 {
474 if (disposing && !_disposed)
475 {
476 _disposed = true;
477 _handler?.Dispose();
478 }
479 base.Dispose(disposing);
480 }
481
483 {
488 {
490 if (activityHeadersPropagator != null)
491 {
493 }
494 }
495 if (httpConnectionSettings._allowAutoRedirect)
496 {
497 HttpMessageHandlerStage redirectInnerHandler = ((httpConnectionSettings._credentials == null || httpConnectionSettings._credentials is CredentialCache) ? httpMessageHandlerStage : new HttpConnectionHandler(poolManager));
499 }
500 if (httpConnectionSettings._automaticDecompression != 0)
501 {
503 }
505 {
506 httpMessageHandlerStage.Dispose();
507 }
508 return _handler;
509 }
510
512 {
513 if (request == null)
514 {
516 }
517 if (request.Version.Major >= 2)
518 {
520 }
521 if (request.VersionPolicy == HttpVersionPolicy.RequestVersionOrHigher)
522 {
524 }
526 cancellationToken.ThrowIfCancellationRequested();
529 if (ex != null)
530 {
531 throw ex;
532 }
534 }
535
555
557 {
558 if (request.Version.Major == 0)
559 {
561 }
562 if (request.HasHeaders && request.Headers.TransferEncodingChunked.GetValueOrDefault())
563 {
564 if (request.Content == null)
565 {
567 }
568 request.Content.Headers.ContentLength = null;
569 }
570 else if (request.Content != null && !request.Content.Headers.ContentLength.HasValue)
571 {
572 request.Headers.TransferEncodingChunked = true;
573 }
574 if (request.Version.Minor == 0 && request.Version.Major == 1 && request.HasHeaders)
575 {
576 if (request.Headers.TransferEncodingChunked == true)
577 {
579 }
580 if (request.Headers.ExpectContinue == true)
581 {
582 request.Headers.ExpectContinue = false;
583 }
584 }
585 Uri requestUri = request.RequestUri;
586 if ((object)requestUri == null || !requestUri.IsAbsoluteUri)
587 {
589 }
591 {
593 }
594 return null;
595 }
596}
HeaderEncodingSelector< HttpRequestMessage > _responseHeaderEncodingSelector
HeaderEncodingSelector< HttpRequestMessage > _requestHeaderEncodingSelector
Func< SocketsHttpPlaintextStreamFilterContext, CancellationToken, ValueTask< Stream > > _plaintextStreamFilter
DistributedContextPropagator _activityHeadersPropagator
Func< SocketsHttpConnectionContext, CancellationToken, ValueTask< Stream > > _connectCallback
virtual void Dispose(bool disposing)
static bool IsSupportedScheme(string scheme)
Func< SocketsHttpConnectionContext, CancellationToken, ValueTask< Stream > >? ConnectCallback
SslClientAuthenticationOptions SslOptions
override void Dispose(bool disposing)
DistributedContextPropagator? ActivityHeadersPropagator
Exception ValidateAndNormalizeRequest(HttpRequestMessage request)
override Task< HttpResponseMessage > SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
IDictionary< string, object?> Properties
HttpKeepAlivePingPolicy KeepAlivePingPolicy
HttpMessageHandlerStage SetupHandlerChain()
HeaderEncodingSelector< HttpRequestMessage >? ResponseHeaderEncodingSelector
readonly HttpConnectionSettings _settings
DecompressionMethods AutomaticDecompression
override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
HeaderEncodingSelector< HttpRequestMessage >? RequestHeaderEncodingSelector
Func< SocketsHttpPlaintextStreamFilterContext, CancellationToken, ValueTask< Stream > >? PlaintextStreamFilter
static string net_http_http2_sync_not_supported
Definition SR.cs:196
static string net_http_unsupported_version
Definition SR.cs:138
static string net_http_value_must_be_greater_than_or_equal
Definition SR.cs:90
static string net_http_value_must_be_greater_than
Definition SR.cs:88
static string net_http_chunked_not_allowed_with_empty_content
Definition SR.cs:86
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_client_invalid_requesturi
Definition SR.cs:62
static string net_http_client_execution_error
Definition SR.cs:58
static string net_http_upgrade_not_enabled_sync
Definition SR.cs:198
static string net_http_handler_norequest
Definition SR.cs:70
static string net_http_http2_invalidinitialstreamwindowsize
Definition SR.cs:152
static string net_http_unsupported_chunking
Definition SR.cs:136
static string net_http_unsupported_requesturi_scheme
Definition SR.cs:64
static string net_http_operation_started
Definition SR.cs:56
static string ArgumentOutOfRange_NeedNonNegativeNum
Definition SR.cs:126
Definition SR.cs:7
static int CompareExchange(ref int location1, int value, int comparand)
static Task FromException(Exception exception)
Definition Task.cs:3341
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363
static readonly TimeSpan InfiniteTimeSpan
Definition Timeout.cs:5
static TimeSpan FromSeconds(double value)
Definition TimeSpan.cs:247
static readonly TimeSpan Zero
Definition TimeSpan.cs:21