HandleFinishSendAsyncCleanup() private method

private HandleFinishSendAsyncCleanup ( HttpRequestMessage request, CancellationTokenSource cts, bool disposeCts ) : void
request HttpRequestMessage
cts System.Threading.CancellationTokenSource
disposeCts bool
return void
Exemplo n.º 1
0
        private async Task <HttpResponseMessage> FinishSendAsyncUnbuffered(
            Task <HttpResponseMessage> sendTask,
            HttpRequestMessage request,
            CancellationTokenSource cts,
            bool disposeCts)
        {
            HttpClient          httpClient = this;
            HttpResponseMessage httpResponseMessage;

            try
            {
                HttpResponseMessage response = await sendTask.ConfigureAwait(false);

                if (response == null)
                {
                    throw new InvalidOperationException(SR.net_http_handler_noresponse);
                }
                if (NetEventSource.IsEnabled)
                {
                    NetEventSource.ClientSendCompleted(httpClient, response, request);
                }
                httpResponseMessage = response;
            }
            catch (Exception ex)
            {
                httpClient.HandleFinishSendAsyncError(ex, cts);
                throw;
            }
            finally
            {
                httpClient.HandleFinishSendAsyncCleanup(cts, disposeCts);
            }
            return(httpResponseMessage);
        }