• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Http.HttpMessageHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



HttpMessageHandler类属于System.Net.Http命名空间,在下文中一共展示了HttpMessageHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SplunkContext

 /// <summary>
 /// Creates an instance of the SplunkViaHttp context
 /// </summary>
 public SplunkContext(SplunkClient.Scheme scheme, string host, int port, string index, string username, string password, TimeSpan timeout, HttpMessageHandler handler, bool disposeHandler = true)
     : base(scheme, host, port, timeout, handler, disposeHandler)
 {
     Index = index;
     Username = username;
     Password = password;
 }
开发者ID:bry4ngh0st,项目名称:serilog-sinks-splunk,代码行数:10,代码来源:SplunkContext.cs


示例2: DelegatingHandler

		protected DelegatingHandler(HttpMessageHandler innerHandler)
		{
			if (innerHandler == null)
				throw new ArgumentNullException ("innerHandler");
			
			InnerHandler = innerHandler;
		}
开发者ID:mgranell,项目名称:mono,代码行数:7,代码来源:DelegatingHandler.cs


示例3: RetryHandler

 /// <summary>
 /// Initializes a new instance of the <see cref="RetryHandler" /> class.
 /// </summary>
 /// <param name="innerHandler">The inner handler. (Usually new HttpClientHandler())</param>
 /// <param name="maxRetries">The maximum retries.</param>
 /// <param name="retryDelayMilliseconds">The retry delay milliseconds.</param>
 /// <param name="logger">The optional logger to log error messages to.</param>
 /// <remarks>
 /// When only the auth0 token provider is injected, the auth0 token provider should try to extract the client id from the 401 response header.
 /// </remarks>
 public RetryHandler(HttpMessageHandler innerHandler, uint maxRetries = 1, uint retryDelayMilliseconds = 500, ILogger logger = null)
     : base(innerHandler)
 {
     this.maxRetries = maxRetries;
     this.retryDelayMilliseconds = retryDelayMilliseconds;
     this.logger = logger;
 }
开发者ID:Cimpress-MCP,项目名称:dotnet-core-httputils,代码行数:17,代码来源:RetryHandler.cs


示例4: OAuthMessageHandler

		public OAuthMessageHandler(HttpMessageHandler innerHandler, IHmacSha1HashProvider hashProvider, string consumerKey, string consumerSecret, Token oAuthToken)
			: base(innerHandler)
		{
            if (hashProvider == null)
                throw new ArgumentNullException("hashProvider");

			if (consumerKey == null)
				throw new ArgumentNullException("consumerKey");

			if (consumerKey.Length == 0)
				throw new ArgumentException("Consumer key cannot be empty.", "consumerKey");

			if (consumerSecret == null)
				throw new ArgumentNullException("consumerSecret");

			if (consumerSecret.Length == 0)
				throw new ArgumentException("Consumer secret cannot be empty.", "consumerSecret");

			if(oAuthToken != null && !oAuthToken.IsValid)
				throw new ArgumentException("OAuth token is not valid.", "oAuthToken");

            if (consumerKey == null)
                throw new ArgumentNullException("consumerKey");

            this.hashProvider = hashProvider;
			this.consumerKey = consumerKey;
			this.consumerSecret = consumerSecret;
			this.oAuthToken = oAuthToken;
		}
开发者ID:jakelauer,项目名称:Vanilla,代码行数:29,代码来源:OAuthMessageHandler.cs


示例5: MapSensorRoutes

        /// <summary>
        /// Configures API routes to expose sensors.
        /// </summary>
        /// <param name="configuration">The HTTP configuration.</param>
        /// <param name="authorizeRequest">A delegate providing a method to authorize or deny sensor requests.</param>
        /// <param name="baseUri">The base URI at which sensors will be routed.</param>
        /// <param name="handler">An optional message handler to be invoked when sensors are called.</param>
        /// <returns>
        /// The updated <see cref="HttpConfiguration" />.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">configuration
        /// or
        /// authorizeRequest</exception>
        public static HttpConfiguration MapSensorRoutes(
            this HttpConfiguration configuration,
            Func<HttpActionContext, bool> authorizeRequest,
            string baseUri = "sensors",
            HttpMessageHandler handler = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (authorizeRequest == null)
            {
                throw new ArgumentNullException(nameof(authorizeRequest));
            }

            AuthorizeSensorsAttribute.AuthorizeRequest = authorizeRequest;

            configuration.Routes.MapHttpRoute(
                "Its-Log-Monitoring-Sensors",
                baseUri.AppendSegment("{name}"),
                defaults: new
                {
                    controller = "Sensor",
                    name = RouteParameter.Optional
                },
                constraints: null,
                handler: handler);

            return configuration;
        }
开发者ID:PhillipPruett,项目名称:Its.Log,代码行数:43,代码来源:HttpConfigurationExtensions.cs


示例6: HttpClient

		public HttpClient (HttpMessageHandler handler, bool disposeHandler)
			: base (handler, disposeHandler)
		{
			buffer_size = int.MaxValue;
			timeout = TimeoutDefault;
			cts = new CancellationTokenSource ();
		}
开发者ID:LevNNN,项目名称:mono,代码行数:7,代码来源:HttpClient.cs


示例7: UseWebApiWithContainer

 public static IAppBuilder UseWebApiWithContainer(this IAppBuilder app, HttpConfiguration configuration, HttpMessageHandler dispatcher)
 {
     IServiceProvider appContainer = app.GetApplicationContainer();
     configuration.DependencyResolver = new OwinDependencyResolverWebApiAdapter(appContainer);
     HttpServer httpServer = new OwinDependencyScopeHttpServerAdapter(configuration, dispatcher);
     return app.UseWebApi(httpServer);
 }
开发者ID:dev-informatics,项目名称:DotNetDoodle.Owin.Dependencies,代码行数:7,代码来源:OwinExtensions.cs


示例8: OpenSrsClient

 public OpenSrsClient(OpenSrsMode openSrsMode, string username, string apiKey, HttpMessageHandler httpMessageHandler)
 {
     HttpClient = new HttpClient(httpMessageHandler);
     OpenSrsMode = openSrsMode;
     Username = username;
     ApiKey = apiKey;
 }
开发者ID:gitter-badger,项目名称:NOpenSRS,代码行数:7,代码来源:OpenSrsClient.cs


示例9: Create

        /// <summary>
        /// Creates an instance of an <see cref="HttpMessageHandler"/> using the <see cref="DelegatingHandler"/> instances
        /// provided by <paramref name="handlers"/>.
        /// </summary>
        /// <param name="handlers">An ordered list of <see cref="DelegatingHandler"/> instances to be invoked as an 
        /// <see cref="HttpRequestMessage"/> travels up the stack and an <see cref="HttpResponseMessage"/> travels down.</param>
        /// <param name="innerChannel">The inner channel represents the destination of the HTTP message channel.</param>
        /// <returns>The HTTP message channel.</returns>
        public static HttpMessageHandler Create(IEnumerable<DelegatingHandler> handlers, HttpMessageHandler innerChannel)
        {
            if (innerChannel == null)
            {
                throw Error.ArgumentNull("innerChannel");
            }

            if (handlers == null)
            {
                return innerChannel;
            }

            // Wire handlers up
            HttpMessageHandler pipeline = innerChannel;
            foreach (DelegatingHandler handler in handlers)
            {
                if (handler == null)
                {
                    throw Error.Argument("handlers", SRResources.DelegatingHandlerArrayContainsNullItem, typeof(DelegatingHandler).Name);
                }

                if (handler.InnerHandler != null)
                {
                    throw Error.Argument("handlers", SRResources.DelegatingHandlerArrayHasNonNullInnerHandler, typeof(DelegatingHandler).Name, "InnerHandler", handler.GetType().Name);
                }

                handler.InnerHandler = pipeline;
                pipeline = handler;
            }

            return pipeline;
        }
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:40,代码来源:HttpPipelineFactory.cs


示例10: CreatePipeline

        /// <summary>
        /// Creates an instance of an <see cref="HttpMessageHandler"/> using the <see cref="DelegatingHandler"/> instances
        /// provided by <paramref name="handlers"/>. The resulting pipeline can be used to manually create <see cref="HttpClient"/>
        /// or <see cref="HttpMessageInvoker"/> instances with customized message handlers.
        /// </summary>
        /// <param name="innerHandler">The inner handler represents the destination of the HTTP message channel.</param>
        /// <param name="handlers">An ordered list of <see cref="DelegatingHandler"/> instances to be invoked as part 
        /// of sending an <see cref="HttpRequestMessage"/> and receiving an <see cref="HttpResponseMessage"/>.
        /// The handlers are invoked in a top-down fashion. That is, the first entry is invoked first for 
        /// an outbound request message but last for an inbound response message.</param>
        /// <returns>The HTTP message channel.</returns>
        public static HttpMessageHandler CreatePipeline(HttpMessageHandler innerHandler, IEnumerable<DelegatingHandler> handlers)
        {
            if (innerHandler == null)
            {
                throw Error.ArgumentNull("innerHandler");
            }

            if (handlers == null)
            {
                return innerHandler;
            }

            // Wire handlers up in reverse order starting with the inner handler
            HttpMessageHandler pipeline = innerHandler;
            IEnumerable<DelegatingHandler> reversedHandlers = handlers.Reverse();
            foreach (DelegatingHandler handler in reversedHandlers)
            {
                if (handler == null)
                {
                    throw Error.Argument("handlers", Properties.Resources.DelegatingHandlerArrayContainsNullItem, typeof(DelegatingHandler).Name);
                }

                if (handler.InnerHandler != null)
                {
                    throw Error.Argument("handlers", Properties.Resources.DelegatingHandlerArrayHasNonNullInnerHandler, typeof(DelegatingHandler).Name, "InnerHandler", handler.GetType().Name);
                }

                handler.InnerHandler = pipeline;
                pipeline = handler;
            }

            return pipeline;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:44,代码来源:HttpClientFactory.cs


示例11: MakeClient

 protected virtual HttpClient MakeClient(HttpMessageHandler handler)
 {
     return new HttpClient(handler)
     {
         Timeout = TimeSpan.FromMilliseconds(int.MaxValue) // Longest TimeSpan HttpClient will accept
     };
 }
开发者ID:EdsonAlcala,项目名称:libvideo,代码行数:7,代码来源:VideoClient.cs


示例12: InstagramApi

		public InstagramApi(string identifier, string clientId, string clientSecret, string redirectUrl, HttpMessageHandler handler = null)
			: base(identifier, clientId, clientSecret, handler)
		{
			this.TokenUrl = "https://api.instagram.com/oauth/access_token";
			this.RedirectUrl = new Uri(redirectUrl);
			Scopes = new[] { "basic" };
		}
开发者ID:Clancey,项目名称:SimpleAuth,代码行数:7,代码来源:Instagram.cs


示例13: AsyncClient

 public AsyncClient(
     string auth,
     int timeout,
     ProductInfoHeaderValue userAgent,
     HttpMessageHandler httpMessageHandler = null
     )
 {
     _httpMessageHandler = httpMessageHandler ?? new HttpClientHandler();
     try
     {
         _httpClient = new HttpClient(_httpMessageHandler)
         {
             DefaultRequestHeaders =
             {
                 Authorization = new AuthenticationHeaderValue("Basic", auth),
                 Accept = {new MediaTypeWithQualityHeaderValue("application/json")},
                 UserAgent = {userAgent}
             },
             Timeout = TimeSpan.FromMilliseconds(timeout)
         };
     }
     catch
     {
         _httpClient?.Dispose();
         _httpMessageHandler.Dispose();
         throw;
     }
 }
开发者ID:choban49,项目名称:GeoIP2-dotnet,代码行数:28,代码来源:AsyncClient.cs


示例14: BaseServerCompressionHandler

        /// <summary>
        /// Initializes a new instance of the <see cref="ServerCompressionHandler" /> class.
        /// </summary>
        /// <param name="innerHandler">The inner handler.</param>
        /// <param name="contentSizeThreshold">The content size threshold before compressing.</param>
        /// <param name="enableCompression">Custom delegate to enable or disable compression.</param>
        /// <param name="compressors">The compressors.</param>
        protected BaseServerCompressionHandler(HttpMessageHandler innerHandler, int contentSizeThreshold, Predicate<HttpRequestMessage> enableCompression, params ICompressor[] compressors)
        {
            if (innerHandler != null)
            {
                this.InnerHandler = innerHandler;
            }

            this.Compressors = compressors;
            this.contentSizeThreshold = contentSizeThreshold;
            this.httpContentOperations = new HttpContentOperations();

            this.enableCompression = enableCompression ?? (x =>
            {
                // If request does not accept gzip or deflate, return false
                if (x.Headers.AcceptEncoding.All(y => y.Value != "gzip" && y.Value != "deflate"))
                {
                    return false;
                }

                // If compression has been explicitly disabled, return false
                if (x.Properties.ContainsKey("compression:Enable"))
                {
                    bool enable;
                    bool.TryParse(x.Properties["compression:Enable"].ToString(), out enable);

                    return enable;
                }

                return true;
            });
        }
开发者ID:SneakyMax,项目名称:Microsoft.AspNet.WebApi.MessageHandlers.Compression,代码行数:38,代码来源:BaseServerCompressionHandler.cs


示例15: RedisCacheHandler

 /// <summary>
 /// Used internally only for unit testing.
 /// </summary>
 /// <param name="innerHandler">The inner handler to retrieve the content from on cache misses.</param>
 /// <param name="cacheExpirationPerHttpResponseCode">A mapping of HttpStatusCode to expiration times. If unspecified takes a default value.</param>
 /// <param name="cache">The distributed cache to use.</param>
 /// /// <param name="statsProvider">An <see cref="IStatsProvider"/> that records statistic information about the caching behavior.</param>
 internal RedisCacheHandler(HttpMessageHandler innerHandler, IDictionary<HttpStatusCode, TimeSpan> cacheExpirationPerHttpResponseCode, IDistributedCache cache,
     IStatsProvider statsProvider = null) : base(innerHandler ?? new HttpClientHandler())
 {
     this.StatsProvider = statsProvider ?? new StatsProvider(nameof(RedisCacheHandler));
     this.cacheExpirationPerHttpResponseCode = cacheExpirationPerHttpResponseCode ?? new Dictionary<HttpStatusCode, TimeSpan>();
     responseCache = cache;
 }
开发者ID:Cimpress-MCP,项目名称:dotnet-core-httputils,代码行数:14,代码来源:RedisCacheHandler.cs


示例16: CreateClient

		public IHalHttpClient CreateClient(HttpMessageHandler httpMessageHandler)
		{
			if (httpMessageHandler == null)
				throw new ArgumentNullException(nameof(httpMessageHandler));

			return CreateHalHttpClient(GetHttpClient(httpMessageHandler));
		}
开发者ID:jabbera,项目名称:HalClient.Net,代码行数:7,代码来源:HalHttpClientFactory.cs


示例17: CreateClientAsync

		public Task<IHalHttpClient> CreateClientAsync(HttpMessageHandler httpMessageHandler, CachingBehavior apiRootCachingBehavior = CachingBehavior.Never)
		{
			if (httpMessageHandler == null)
				throw new ArgumentNullException(nameof(httpMessageHandler));

			return CreateHalHttpClientAsync(GetHttpClient(httpMessageHandler), apiRootCachingBehavior);
		}
开发者ID:jabbera,项目名称:HalClient.Net,代码行数:7,代码来源:HalHttpClientFactory.cs


示例18: Create

        public IRdfeIaasClustersRestClient Create(
            HttpMessageHandler defaultHttpClientHandler,
            IHDInsightSubscriptionCredentials credentials,
            IAbstractionContext context,
            bool ignoreSslErrors)
        {
            HttpRestClientRetryPolicy retryPolicy = null;
            var tokenCreds = credentials as IHDInsightAccessTokenCredential;

            var customHandlers = new List<DelegatingHandler>();

            if (context != null && context.Logger != null)
            {
                customHandlers.Add(new HttpLoggingHandler(context.Logger));
                retryPolicy = new HttpRestClientRetryPolicy(context.RetryPolicy);
            }
            else
            {
                retryPolicy = new HttpRestClientRetryPolicy(RetryPolicyFactory.CreateExponentialRetryPolicy());
                customHandlers.Add(new HttpLoggingHandler(new Logger()));
            }

            if (tokenCreds != null)
            {
                customHandlers.Add(new BearerTokenMessageHandler(tokenCreds.AccessToken));
            }

            var httpConfiguration = new HttpRestClientConfiguration(defaultHttpClientHandler, customHandlers, retryPolicy);
            var client = new RdfeIaasClustersRestClient(credentials.Endpoint, httpConfiguration);
            return client;
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:31,代码来源:RdfeIaasClustersRestClientFactory.cs


示例19: HttpMessageInvoker

		//
		// Summary:
		//     Initializes an instance of a System.Net.Http.HttpMessageInvoker class with
		//     a specific System.Net.Http.HttpMessageHandler.
		//
		// Parameters:
		//   handler:
		//     The System.Net.Http.HttpMessageHandler responsible for processing the HTTP
		//     response messages.
		//
		//   disposeHandler:
		//     true if the inner handler should be disposed of by Dispose(),false if you
		//     intend to reuse the inner handler.
		public HttpMessageInvoker(HttpMessageHandler handler, bool disposeHandler)
		{
			if (handler == null)
				throw new ArgumentNullException("handler");
			m_handler = handler;
			m_disposeHandler = disposeHandler;
		}
开发者ID:modulexcite,项目名称:SharpGIS.HttpClient.WP,代码行数:20,代码来源:HttpMessageInvoker.cs


示例20: TwitterOAuthMessageHandler

        public TwitterOAuthMessageHandler(OAuthCredential oAuthCredential, OAuthSignatureEntity signatureEntity,
            TwitterQueryCollection parameters, HttpMessageHandler innerHandler)
            : base(innerHandler)
        {
            //TODO: Parameters needs to come here as encoded so that they can be encoded twice
            //      for the signature base. Handle that.

            //TODO: We don't even need to get parameters seperately. We can get them through
            //      query string and by reading the body but reading the body is a overhead here.

            _oAuthState = new OAuthState() {
                Credential = new OAuthCredentialState() {
                    ConsumerKey = oAuthCredential.ConsumerKey,
                    //encode it here first
                    CallbackUrl = OAuthUtil.PercentEncode(oAuthCredential.CallbackUrl),
                    Token = oAuthCredential.Token
                },
                SignatureEntity = new OAuthSignatureEntityState() {
                    ConsumerSecret = signatureEntity.ConsumerSecret,
                    TokenSecret = signatureEntity.TokenSecret
                },
                Parameters = parameters,
                Nonce = GenerateNonce(),
                SignatureMethod = GetOAuthSignatureMethod(),
                Timestamp = GenerateTimestamp(),
                Version = GetVersion()
            };
        }
开发者ID:tugberkugurlu,项目名称:TwitterDoodle,代码行数:28,代码来源:TwitterOAuthMessageHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Http.HttpMessageInvoker类代码示例发布时间:2022-05-26
下一篇:
C# Http.HttpContent类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap