protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     AllowCookies                = elementToBeCloned.AllowCookies;
     AuthenticationScheme        = elementToBeCloned.AuthenticationScheme;
     BypassProxyOnLocal          = elementToBeCloned.BypassProxyOnLocal;
     _decompressionEnabled       = elementToBeCloned._decompressionEnabled;
     _hostNameComparisonMode     = elementToBeCloned._hostNameComparisonMode;
     _inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     KeepAliveEnabled            = elementToBeCloned.KeepAliveEnabled;
     _maxBufferSize              = elementToBeCloned._maxBufferSize;
     _maxBufferSizeInitialized   = elementToBeCloned._maxBufferSizeInitialized;
     _maxPendingAccepts          = elementToBeCloned._maxPendingAccepts;
     _method      = elementToBeCloned._method;
     Proxy        = elementToBeCloned.Proxy;
     ProxyAddress = elementToBeCloned.ProxyAddress;
     _proxyAuthenticationScheme = elementToBeCloned._proxyAuthenticationScheme;
     _realm = elementToBeCloned._realm;
     _requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout;
     _transferMode = elementToBeCloned._transferMode;
     UnsafeConnectionNtlmAuthentication = elementToBeCloned.UnsafeConnectionNtlmAuthentication;
     _useDefaultWebProxy       = elementToBeCloned._useDefaultWebProxy;
     _webSocketSettings        = elementToBeCloned._webSocketSettings.Clone();
     _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     MessageHandlerFactory     = elementToBeCloned.MessageHandlerFactory;
 }
Beispiel #2
0
 protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     this.allowCookies               = elementToBeCloned.allowCookies;
     this.authenticationScheme       = elementToBeCloned.authenticationScheme;
     this.bypassProxyOnLocal         = elementToBeCloned.bypassProxyOnLocal;
     this.decompressionEnabled       = elementToBeCloned.decompressionEnabled;
     this.hostNameComparisonMode     = elementToBeCloned.hostNameComparisonMode;
     this.inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     this.keepAliveEnabled           = elementToBeCloned.keepAliveEnabled;
     this.maxBufferSize              = elementToBeCloned.maxBufferSize;
     this.maxBufferSizeInitialized   = elementToBeCloned.maxBufferSizeInitialized;
     this.maxPendingAccepts          = elementToBeCloned.maxPendingAccepts;
     this.method       = elementToBeCloned.method;
     this.proxyAddress = elementToBeCloned.proxyAddress;
     this.proxyAuthenticationScheme = elementToBeCloned.proxyAuthenticationScheme;
     this.realm = elementToBeCloned.realm;
     this.requestInitializationTimeout = elementToBeCloned.requestInitializationTimeout;
     this.transferMode = elementToBeCloned.transferMode;
     this.unsafeConnectionNtlmAuthentication = elementToBeCloned.unsafeConnectionNtlmAuthentication;
     this.useDefaultWebProxy       = elementToBeCloned.useDefaultWebProxy;
     this.webSocketSettings        = elementToBeCloned.webSocketSettings.Clone();
     this.webProxy                 = elementToBeCloned.webProxy;
     this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     if (elementToBeCloned.anonymousUriPrefixMatcher != null)
     {
         this.anonymousUriPrefixMatcher = new HttpAnonymousUriPrefixMatcher(elementToBeCloned.anonymousUriPrefixMatcher);
     }
     this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
 }
Beispiel #3
0
        internal static WebSocketTransportSettings GetRuntimeWebSocketSettings(WebSocketTransportSettings settings)
        {
            WebSocketTransportSettings runtimeSettings = settings.Clone();

            if (runtimeSettings.MaxPendingConnections == WebSocketDefaults.DefaultMaxPendingConnections)
            {
                runtimeSettings.MaxPendingConnections = WebSocketDefaults.MaxPendingConnectionsCpuCount;
            }

            return(runtimeSettings);
        }
Beispiel #4
0
 public HttpTransportBindingElement()
     : base()
 {
     _allowCookies           = HttpTransportDefaults.AllowCookies;
     _authenticationScheme   = HttpTransportDefaults.AuthenticationScheme;
     _decompressionEnabled   = HttpTransportDefaults.DecompressionEnabled;
     _hostNameComparisonMode = HttpTransportDefaults.HostNameComparisonMode;
     _keepAliveEnabled       = HttpTransportDefaults.KeepAliveEnabled;
     _maxBufferSize          = TransportDefaults.MaxBufferSize;
     _maxPendingAccepts      = HttpTransportDefaults.DefaultMaxPendingAccepts;
     _method = string.Empty;
     _realm  = HttpTransportDefaults.Realm;
     _requestInitializationTimeout = HttpTransportDefaults.RequestInitializationTimeout;
     _transferMode = HttpTransportDefaults.TransferMode;
     _unsafeConnectionNtlmAuthentication = HttpTransportDefaults.UnsafeConnectionNtlmAuthentication;
     _useDefaultWebProxy = HttpTransportDefaults.UseDefaultWebProxy;
     _webSocketSettings  = HttpTransportDefaults.GetDefaultWebSocketTransportSettings();
 }
        public override async Task <WebSocket> CreateWebSocketAsync(Uri address, WebHeaderCollection headers, ICredentials credentials,
                                                                    WebSocketTransportSettings settings, TimeoutHelper timeoutHelper)
        {
            ClientWebSocket webSocket = new ClientWebSocket();

            webSocket.Options.Credentials = credentials;
            webSocket.Options.AddSubProtocol(settings.SubProtocol);
            webSocket.Options.KeepAliveInterval = settings.KeepAliveInterval;
            foreach (var headerObj in headers)
            {
                var header = headerObj as string;
                webSocket.Options.SetRequestHeader(header, headers[header]);
            }

            await webSocket.ConnectAsync(address, timeoutHelper.CancellationToken);

            return(webSocket);
        }
Beispiel #6
0
 public HttpTransportBindingElement()
     : base()
 {
     this.allowCookies           = HttpTransportDefaults.AllowCookies;
     this.authenticationScheme   = HttpTransportDefaults.AuthenticationScheme;
     this.bypassProxyOnLocal     = HttpTransportDefaults.BypassProxyOnLocal;
     this.decompressionEnabled   = HttpTransportDefaults.DecompressionEnabled;
     this.hostNameComparisonMode = HttpTransportDefaults.HostNameComparisonMode;
     this.keepAliveEnabled       = HttpTransportDefaults.KeepAliveEnabled;
     this.maxBufferSize          = TransportDefaults.MaxBufferSize;
     this.maxPendingAccepts      = HttpTransportDefaults.DefaultMaxPendingAccepts;
     this.method = string.Empty;
     this.proxyAuthenticationScheme = HttpTransportDefaults.ProxyAuthenticationScheme;
     this.proxyAddress = HttpTransportDefaults.ProxyAddress;
     this.realm        = HttpTransportDefaults.Realm;
     this.requestInitializationTimeout = HttpTransportDefaults.RequestInitializationTimeout;
     this.transferMode = HttpTransportDefaults.TransferMode;
     this.unsafeConnectionNtlmAuthentication = HttpTransportDefaults.UnsafeConnectionNtlmAuthentication;
     this.useDefaultWebProxy       = HttpTransportDefaults.UseDefaultWebProxy;
     this.webSocketSettings        = HttpTransportDefaults.GetDefaultWebSocketTransportSettings();
     this.webProxy                 = null;
     this.extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 }
Beispiel #7
0
        protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
            : base(elementToBeCloned)
        {
            _allowCookies               = elementToBeCloned._allowCookies;
            _authenticationScheme       = elementToBeCloned._authenticationScheme;
            _decompressionEnabled       = elementToBeCloned._decompressionEnabled;
            _hostNameComparisonMode     = elementToBeCloned._hostNameComparisonMode;
            _inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
            _keepAliveEnabled           = elementToBeCloned._keepAliveEnabled;
            _maxBufferSize              = elementToBeCloned._maxBufferSize;
            _maxBufferSizeInitialized   = elementToBeCloned._maxBufferSizeInitialized;
            _maxPendingAccepts          = elementToBeCloned._maxPendingAccepts;
            _method = elementToBeCloned._method;
            _realm  = elementToBeCloned._realm;
            _requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout;
            _transferMode = elementToBeCloned._transferMode;
            _unsafeConnectionNtlmAuthentication = elementToBeCloned._unsafeConnectionNtlmAuthentication;
            _useDefaultWebProxy = elementToBeCloned._useDefaultWebProxy;
            _webSocketSettings  = elementToBeCloned._webSocketSettings.Clone();
#if !FEATURE_NETNATIVE
            _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
#endif // !FEATURE_NETNATIVE
            this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
        }
Beispiel #8
0
        internal static WebSocketTransportSettings GetRuntimeWebSocketSettings(WebSocketTransportSettings settings)
        {
            WebSocketTransportSettings runtimeSettings = settings.Clone();

            return(runtimeSettings);
        }
Beispiel #9
0
 public abstract Task <WebSocket> CreateWebSocketAsync(Uri address, WebHeaderCollection headers, ICredentials credentials, WebSocketTransportSettings settings, TimeoutHelper timeoutHelper);
Beispiel #10
0
        internal HttpChannelFactory(HttpTransportBindingElement bindingElement, BindingContext context)
            : base(bindingElement, context, HttpTransportDefaults.GetDefaultMessageEncoderFactory())
        {
            // validate setting interactions
            if (bindingElement.TransferMode == TransferMode.Buffered)
            {
                if (bindingElement.MaxReceivedMessageSize > int.MaxValue)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new ArgumentOutOfRangeException("bindingElement.MaxReceivedMessageSize",
                                                              SR.MaxReceivedMessageSizeMustBeInIntegerRange));
                }

                if (bindingElement.MaxBufferSize != bindingElement.MaxReceivedMessageSize)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement",
                                                                                 SR.MaxBufferSizeMustMatchMaxReceivedMessageSize);
                }
            }
            else
            {
                if (bindingElement.MaxBufferSize > bindingElement.MaxReceivedMessageSize)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement",
                                                                                 SR.MaxBufferSizeMustNotExceedMaxReceivedMessageSize);
                }
            }

            if (TransferModeHelper.IsRequestStreamed(bindingElement.TransferMode) &&
                bindingElement.AuthenticationScheme != AuthenticationSchemes.Anonymous)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement",
                                                                             SR.HttpAuthDoesNotSupportRequestStreaming);
            }

            _allowCookies = bindingElement.AllowCookies;

            if (_allowCookies)
            {
                _httpCookieContainerManager = new HttpCookieContainerManager();
            }

            if (!bindingElement.AuthenticationScheme.IsSingleton())
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR.Format(SR.HttpRequiresSingleAuthScheme,
                                                                                                bindingElement.AuthenticationScheme));
            }
            _authenticationScheme = bindingElement.AuthenticationScheme;
            _maxBufferSize        = bindingElement.MaxBufferSize;
            _transferMode         = bindingElement.TransferMode;
            _useDefaultWebProxy   = bindingElement.UseDefaultWebProxy;

            _channelCredentials   = context.BindingParameters.Find <SecurityCredentialsManager>();
            _securityCapabilities = bindingElement.GetProperty <ISecurityCapabilities>(context);

            _webSocketSettings = WebSocketHelper.GetRuntimeWebSocketSettings(bindingElement.WebSocketSettings);
            int webSocketBufferSize = WebSocketHelper.ComputeClientBufferSize(MaxReceivedMessageSize);

            _bufferPool               = new ConnectionBufferPool(webSocketBufferSize);
            _clientWebSocketFactory   = ClientWebSocketFactory.GetFactory();
            _webSocketSoapContentType = new Lazy <string>(() => MessageEncoderFactory.CreateSessionEncoder().ContentType, LazyThreadSafetyMode.ExecutionAndPublication);
        }
Beispiel #11
0
 // Provides the client WebSocket for step #2. WCF creates the HttpWebRequest in step #1, and passes the HttpWebResponse stream
 // to this method. The 'settings' argument can optionally be used. On Win8 (and above), the WebSocket.CreateClientWebSocket method
 // requires other arguments (in addition to the Stream) that can be obtained from 'settings'. Since the WebSocket.CreateClientWebSocket
 // finds this argument to be enough to create a client WebSocket (on Win8, and post Win8 due to backward compatibility requirements),
 // we estimate that implementors of a custom web socket factory will find it enough too.
 public abstract WebSocket CreateWebSocket(Stream connection, WebSocketTransportSettings settings);