当前位置: 首页>>代码示例>>C#>>正文


C# HttpClientHandler.SupportsPreAuthenticate方法代码示例

本文整理汇总了C#中System.Net.Http.HttpClientHandler.SupportsPreAuthenticate方法的典型用法代码示例。如果您正苦于以下问题:C# HttpClientHandler.SupportsPreAuthenticate方法的具体用法?C# HttpClientHandler.SupportsPreAuthenticate怎么用?C# HttpClientHandler.SupportsPreAuthenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.HttpClientHandler的用法示例。


在下文中一共展示了HttpClientHandler.SupportsPreAuthenticate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMessageHandler

        private static HttpMessageHandler CreateMessageHandler(ODataClientSettings settings)
        {
            if (settings.OnCreateMessageHandler != null)
            {
                return settings.OnCreateMessageHandler();
            }
            else
            {
                var clientHandler = new HttpClientHandler();

                // Perform this test to prevent failure to access Credentials/PreAuthenticate properties on SL5
                if (settings.Credentials != null)
                {
                    clientHandler.Credentials = settings.Credentials;
                    if (clientHandler.SupportsPreAuthenticate())
                        clientHandler.PreAuthenticate = true;
                }

                if (settings.OnApplyClientHandler != null)
                {
                    settings.OnApplyClientHandler(clientHandler);
                }

                return clientHandler;
            }
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:26,代码来源:HttpConnection.cs

示例2: TokenProvider

        /// <summary>
        /// Create a token provider to authenticate against ArcGIS Server
        /// </summary>
        /// <param name="rootUrl">Made up of scheme://host:port/site</param>
        /// <param name="username">ArcGIS Server user name</param>
        /// <param name="password">ArcGIS Server user password</param>
        /// <param name="serializer">Used to (de)serialize requests and responses</param>
        public TokenProvider(String rootUrl, String username, String password, ISerializer serializer)
        {
            if (String.IsNullOrWhiteSpace(username) || String.IsNullOrWhiteSpace(password))
            {
                System.Diagnostics.Debug.WriteLine("TokenProvider for '" + RootUrl + "' not initialized as username/password not supplied.");
                return;
            }
            if (serializer == null) throw new ArgumentNullException("serializer", "Serializer has not been set.");

            RootUrl = rootUrl.AsRootUrl();
            Serializer = serializer;
            TokenRequest = new GenerateToken(username, password);

            _httpClientHandler = new HttpClientHandler();
            if (_httpClientHandler.SupportsAutomaticDecompression)
                _httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            if (_httpClientHandler.SupportsUseProxy()) _httpClientHandler.UseProxy = true;
            if (_httpClientHandler.SupportsAllowAutoRedirect()) _httpClientHandler.AllowAutoRedirect = true;
            if (_httpClientHandler.SupportsPreAuthenticate()) _httpClientHandler.PreAuthenticate = true;

            _httpClient = new HttpClient(_httpClientHandler);
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            System.Diagnostics.Debug.WriteLine("Created TokenProvider for " + RootUrl);
        }
开发者ID:pheede,项目名称:ArcGIS.PCL,代码行数:32,代码来源:ITokenProvider.cs

示例3: TokenProvider

        /// <summary>
        /// Create a token provider to authenticate against ArcGIS Server
        /// </summary>
        /// <param name="rootUrl">Made up of scheme://host:port/site</param>
        /// <param name="username">ArcGIS Server user name</param>
        /// <param name="password">ArcGIS Server user password</param>
        /// <param name="serializer">Used to (de)serialize requests and responses</param>
        public TokenProvider(String rootUrl, String username, String password, ISerializer serializer)
        {
            RootUrl = rootUrl.AsRootUrl();
            Serializer = serializer;
            if (Serializer == null) throw new ArgumentNullException("serializer", "Serializer has not been set.");
            TokenRequest = new GenerateToken(username, password);

            _httpClientHandler = new HttpClientHandler();
            if (_httpClientHandler.SupportsAutomaticDecompression)
                _httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            if (_httpClientHandler.SupportsUseProxy()) _httpClientHandler.UseProxy = true;
            if (_httpClientHandler.SupportsAllowAutoRedirect()) _httpClientHandler.AllowAutoRedirect = true;
            if (_httpClientHandler.SupportsPreAuthenticate()) _httpClientHandler.PreAuthenticate = true;

            _httpClient = new HttpClient(_httpClientHandler);
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        }
开发者ID:prusinek74,项目名称:ArcGIS.PCL,代码行数:24,代码来源:ITokenProvider.cs


注:本文中的System.Net.Http.HttpClientHandler.SupportsPreAuthenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。