Пример #1
0
 public HttpClientChannelAsyncRequest(HttpClientRequestChannel channel)
 {
     _channel    = channel;
     _to         = channel.RemoteAddress;
     _via        = channel.Via;
     _factory    = channel.Factory;
     _httpClient = _factory.GetHttpClient();
 }
Пример #2
0
 public HttpClientChannelAsyncRequest(HttpClientRequestChannel channel)
 {
     _channel     = channel;
     _to          = channel.RemoteAddress;
     _via         = channel.Via;
     _factory     = channel.Factory;
     _httpClient  = _factory.GetHttpClient();
     _httpSendCts = new CancellationTokenSource();
 }
Пример #3
0
                public async Task SendRequestAsync(Message message, TimeoutHelper timeoutHelper)
                {
                    _timeoutHelper = timeoutHelper;
                    _factory.ApplyManualAddressing(ref _to, ref _via, message);
                    _httpRequestMessage = await _channel.GetHttpRequestMessageAsync(_to, _via, _timeoutHelper.CancellationToken);

                    Message request = message;

                    try
                    {
                        if (_channel.State != CommunicationState.Opened)
                        {
                            // if we were aborted while getting our request or doing correlation,
                            // we need to abort the web request and bail
                            Cleanup();
                            _channel.ThrowIfDisposedOrNotOpen();
                        }

                        HttpOutput httpOutput = HttpOutput.CreateHttpOutput(_httpRequestMessage, _factory, request, _factory.IsChannelBindingSupportEnabled, _factory.GetHttpClient(), _factory._authenticationScheme, _timeoutHelper);

                        bool success = false;
                        try
                        {
                            _httpResponseMessageTask = await httpOutput.SendAsync(_httpRequestMessage);

                            //this.channelBinding = httpOutput.TakeChannelBinding();
                            await httpOutput.CloseAsync();

                            success = true;
                        }
                        finally
                        {
                            if (!success)
                            {
                                httpOutput.Abort(HttpAbortReason.Aborted);
                            }
                        }
                    }
                    finally
                    {
                        if (!object.ReferenceEquals(request, message))
                        {
                            request.Close();
                        }
                    }
                }