Esempio n. 1
0
 protected override HttpOutput GetHttpOutput(Message message)
 {
     if ((this.listenerContext.Request.ContentLength64 == -1L) && !OSEnvironmentHelper.IsVistaOrGreater)
     {
         this.listenerContext.Response.KeepAlive = false;
     }
     else
     {
         this.listenerContext.Response.KeepAlive = base.listener.KeepAliveEnabled;
     }
     return(HttpOutput.CreateHttpOutput(this.listenerContext.Response, base.Listener, message, this.HttpMethod));
 }
Esempio n. 2
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();
                        }
                    }
                }
Esempio n. 3
0
            public override HttpOutput GetHttpOutput(Message message)
            {
                // TODO: Enable KeepAlive setting
                //if (!_httpBindingElement.KeepAlive)
                //{
                //    aspNetContext.Response.Headers["Connection"] = "close";
                //}

                ICompressedMessageEncoder compressedMessageEncoder = HttpTransportSettings.MessageEncoderFactory.Encoder as ICompressedMessageEncoder;

                if (compressedMessageEncoder != null && compressedMessageEncoder.CompressionEnabled)
                {
                    string acceptEncoding = _aspNetContext.Request.Headers[HttpChannelUtilities.AcceptEncodingHeader];
                    compressedMessageEncoder.AddCompressedMessageProperties(message, acceptEncoding);
                }

                return(HttpOutput.CreateHttpOutput(_aspNetContext, HttpTransportSettings, message, HttpMethod));
            }
Esempio n. 4
0
            public override HttpOutput GetHttpOutput(Message message)
            {
                if (HttpTransportSettings.KeepAliveEnabled)
                {
                    _aspNetContext.Response.Headers["Connection"] = "keep-alive";
                }
                else
                {
                    _aspNetContext.Response.Headers["Connection"] = "close";
                }

                if (HttpTransportSettings.MessageEncoderFactory.Encoder is ICompressedMessageEncoder compressedMessageEncoder && compressedMessageEncoder.CompressionEnabled)
                {
                    string acceptEncoding = _aspNetContext.Request.Headers[HttpChannelUtilities.AcceptEncodingHeader];
                    compressedMessageEncoder.AddCompressedMessageProperties(message, acceptEncoding);
                }

                return(HttpOutput.CreateHttpOutput(_aspNetContext, HttpTransportSettings, message, HttpMethod));
            }
Esempio n. 5
0
            public override HttpOutput GetHttpOutput(Message message)
            {
                // work around http.sys keep alive bug with chunked requests, see MB 49676, this is fixed in Vista
                if (listenerContext.Request.ContentLength64 == -1 && !OSEnvironmentHelper.IsVistaOrGreater)
                {
                    listenerContext.Response.KeepAlive = false;
                }
                else
                {
                    listenerContext.Response.KeepAlive = listener.KeepAliveEnabled;
                }
                ICompressedMessageEncoder compressedMessageEncoder = listener.MessageEncoderFactory.Encoder as ICompressedMessageEncoder;

                if (compressedMessageEncoder != null && compressedMessageEncoder.CompressionEnabled)
                {
                    string acceptEncoding = listenerContext.Request.Headers[HttpChannelUtilities.AcceptEncodingHeader];
                    compressedMessageEncoder.AddCompressedMessageProperties(message, acceptEncoding);
                }

                return(HttpOutput.CreateHttpOutput(listenerContext.Response, Listener, message, this.HttpMethod));
            }