Esempio n. 1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Socket socket;

            if (_getSocketAsync != null)
            {
                socket = await _getSocketAsync(request).ConfigureAwait(false);
            }
            else
            {
                socket = await Tcp.ConnectToServerAsync(request.RequestUri.DnsSafeHost, request.RequestUri.Port).ConfigureAwait(false);
            }

            var stream = await _httpSocketClient.GetStreamAsync(socket, request).ConfigureAwait(false);

            await _httpSocketClient.SendRequestAsync(stream, request).ConfigureAwait(false);

            return(await _httpSocketClient.ReceiveResponseAsync(stream, request).ConfigureAwait(false));
        }