private async ValueTask <HttpConnection> CreateConnection(HttpRequestMessage request, HttpConnectionKey key, HttpConnectionPool pool, CancellationToken cancellationToken)
        {
            logger.Trace("HTTP connection handler: Create connection");

            Uri uri = request.RequestUri;

            Stream stream = await ConnectHelper.ConnectAsync(uri.IdnHost, uri.Port).ConfigureAwait(false);

            TransportContext transportContext = null;

            if (uri.Scheme == UriScheme.Https)
            {
                stream = await this.EstablishSslConnection(uri.IdnHost, request, stream, cancellationToken).ConfigureAwait(false);
            }

            return(new HttpConnection(pool, key, uri.IdnHost, stream, transportContext, false));
        }
Exemplo n.º 2
0
 /// <summary>Initializes the waiter.</summary>
 /// <param name="func">The function to invoke if/when <see cref="CreateConnectionAsync"/> is invoked.</param>
 /// <param name="state">The state to pass to <paramref name="func"/> when it's invoked.</param>
 public ConnectionWaiter(HttpConnectionPool pool, Func <TState, ValueTask <HttpConnection> > func, TState state) : base(pool)
 {
     _createConnectionAsync = func;
     _state = state;
 }