Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetHttp11ConnectionAsync()

async ValueTask< HttpConnection > System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync ( HttpRequestMessage request,
bool async,
CancellationToken cancellationToken )
inlineprivate

Definition at line 412 of file HttpConnectionPool.cs.

413 {
415 while (true)
416 {
417 HttpConnection httpConnection = null;
418 lock (SyncObj)
419 {
422 if (count > 0)
423 {
426 goto IL_0095;
427 }
430 }
431 break;
432 IL_0095:
434 {
435 if (System.Net.NetEventSource.Log.IsEnabled())
436 {
437 httpConnection.Trace("Found expired HTTP/1.1 connection in pool.", "GetHttp11ConnectionAsync");
438 }
439 httpConnection.Dispose();
440 continue;
441 }
442 if (!httpConnection.PrepareForReuse(async))
443 {
444 if (System.Net.NetEventSource.Log.IsEnabled())
445 {
446 httpConnection.Trace("Found invalid HTTP/1.1 connection in pool.", "GetHttp11ConnectionAsync");
447 }
448 httpConnection.Dispose();
449 continue;
450 }
451 if (System.Net.NetEventSource.Log.IsEnabled())
452 {
453 httpConnection.Trace("Found usable HTTP/1.1 connection in pool.", "GetHttp11ConnectionAsync");
454 }
455 return httpConnection;
456 }
457 if (System.Net.NetEventSource.Log.IsEnabled())
458 {
459 Trace("No available HTTP/1.1 connections; request queued.", "GetHttp11ConnectionAsync");
460 }
462 try
463 {
464 return await taskCompletionSourceWithCancellation.WaitWithCancellationAsync(async, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
465 }
466 finally
467 {
468 if (HttpTelemetry.Log.IsEnabled())
469 {
470 HttpTelemetry.Log.Http11RequestLeftQueue(stopwatch.GetElapsedTime().TotalMilliseconds);
471 }
472 }
473 }
bool CheckExpirationOnGet(HttpConnectionBase connection)
readonly List< HttpConnection > _availableHttp11Connections
void Trace(string message, [CallerMemberName] string memberName=null)
RequestQueue< HttpConnection > _http11RequestQueue
static readonly System.Net.NetEventSource Log
static Microsoft.Extensions.Internal.ValueStopwatch StartNew()

References System.Net.Http.HttpConnectionPool._availableHttp11Connections, System.Net.Http.HttpConnectionPool._http11RequestQueue, System.Net.Http.HttpConnectionPool._usedSinceLastCleanup, System.cancellationToken, System.Net.Http.HttpConnectionPool.CheckExpirationOnGet(), System.Net.Http.HttpConnectionPool.CheckForHttp11ConnectionInjection(), System.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Net.Http.HttpTelemetry.Log, System.Net.NetEventSource.Log, Microsoft.Extensions.Internal.ValueStopwatch.StartNew(), System.Net.Http.HttpConnectionPool.SyncObj, and System.Net.Http.HttpConnectionPool.Trace().

Referenced by System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync().