public override T GetProperty <T> (BindingContext context)
 {
     // http://blogs.msdn.com/drnick/archive/2007/04/10/interfaces-for-getproperty-part-1.aspx
     if (typeof(T) == typeof(ISecurityCapabilities))
     {
         return((T)(object)new HttpBindingProperties(this));
     }
     if (typeof(T) == typeof(IBindingDeliveryCapabilities))
     {
         return((T)(object)new HttpBindingProperties(this));
     }
     if (typeof(T) == typeof(TransferMode))
     {
         return((T)(object)TransferMode);
     }
     if (typeof(T) == typeof(IHttpCookieContainerManager))
     {
         if (!AllowCookies)
         {
             return(null);
         }
         if (cookie_manager == null)
         {
             cookie_manager = new HttpCookieContainerManager();
         }
         return((T)(object)cookie_manager);
     }
     return(base.GetProperty <T> (context));
 }
        protected HttpTransportBindingElement(
            HttpTransportBindingElement other)
            : base(other)
        {
            allow_cookies         = other.allow_cookies;
            bypass_proxy_on_local = other.bypass_proxy_on_local;
            unsafe_ntlm_auth      = other.unsafe_ntlm_auth;
            use_default_proxy     = other.use_default_proxy;
            keep_alive_enabled    = other.keep_alive_enabled;
            max_buffer_size       = other.max_buffer_size;
            host_cmp_mode         = other.host_cmp_mode;
            proxy_address         = other.proxy_address;
            realm         = other.realm;
            transfer_mode = other.transfer_mode;
            // FIXME: it does not look safe
            timeouts          = other.timeouts;
            auth_scheme       = other.auth_scheme;
            proxy_auth_scheme = other.proxy_auth_scheme;

#if NET_4_0
            DecompressionEnabled           = other.DecompressionEnabled;
            LegacyExtendedProtectionPolicy = other.LegacyExtendedProtectionPolicy;
            ExtendedProtectionPolicy       = other.ExtendedProtectionPolicy;
            cookie_manager = other.cookie_manager;
#endif
        }
        protected HttpCookieContainerBindingElement(HttpCookieContainerBindingElement elementToBeCloned)
        {
            if (elementToBeCloned == null)
            {
                throw new ArgumentNullException("elementToBeCloned");
            }

            manager = new HttpCookieContainerManager(elementToBeCloned.manager);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        protected HttpTransportBindingElement(
            HttpTransportBindingElement elementToBeCloned)
            : base(elementToBeCloned)
        {
            allow_cookies         = elementToBeCloned.allow_cookies;
            bypass_proxy_on_local = elementToBeCloned.bypass_proxy_on_local;
            unsafe_ntlm_auth      = elementToBeCloned.unsafe_ntlm_auth;
            use_default_proxy     = elementToBeCloned.use_default_proxy;
            keep_alive_enabled    = elementToBeCloned.keep_alive_enabled;
            max_buffer_size       = elementToBeCloned.max_buffer_size;
            host_cmp_mode         = elementToBeCloned.host_cmp_mode;
            proxy_address         = elementToBeCloned.proxy_address;
            realm         = elementToBeCloned.realm;
            transfer_mode = elementToBeCloned.transfer_mode;
            // FIXME: it does not look safe
            timeouts          = elementToBeCloned.timeouts;
            auth_scheme       = elementToBeCloned.auth_scheme;
            proxy_auth_scheme = elementToBeCloned.proxy_auth_scheme;

            DecompressionEnabled           = elementToBeCloned.DecompressionEnabled;
            LegacyExtendedProtectionPolicy = elementToBeCloned.LegacyExtendedProtectionPolicy;
            ExtendedProtectionPolicy       = elementToBeCloned.ExtendedProtectionPolicy;
            cookie_manager = elementToBeCloned.cookie_manager;
        }
 public HttpCookieContainerManager(HttpCookieContainerManager original)
 {
     CookieContainer = original.CookieContainer;
 }
 public HttpCookieContainerBindingElement()
 {
     manager = new HttpCookieContainerManager();
 }
Ejemplo n.º 8
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);
        }