yuzd / Httpclientfactory
Licence: mit
safe HttpClient For netcore And netframework
Stars: ✭ 64
Labels
Projects that are alternatives of or similar to Httpclientfactory
Ionic3 Angular43 Httpclient
Example of Ionic 3 and the new Angular 4.3 HTTPClient
Stars: ✭ 20 (-68.75%)
Mutual labels: httpclient
Specflow.netcore
A (hopefully) temporary solution to get SpecFlow and .NET Core to play nice
Stars: ✭ 43 (-32.81%)
Mutual labels: netcore
Restfulsense
A RESTFul operations client that serializes responses and throws meaningful exceptions for >= 400 status codes.
Stars: ✭ 28 (-56.25%)
Mutual labels: netcore
Entityframeworkcore.indexattribute
Revival of [Index] attribute for EF Core. (with extension for model building.)
Stars: ✭ 37 (-42.19%)
Mutual labels: netcore
Efcore.demo
Projetos com os novos recursos do Entity Framework Core
Stars: ✭ 50 (-21.87%)
Mutual labels: netcore
Dnczeus
DncZeus 是一个基于ASP.NET Core 3 + Vue.js(iview-admin) 的前后端分离的通用后台权限(页面访问、操作按钮控制)管理系统框架。后端使用.NET Core 3 + Entity Framework Core构建,UI则是目前流行的基于Vue.js的iView(iview-admin)。项目实现了前后端的动态权限管理和控制以及基于JWT的用户令牌认证机制,让前后端的交互更流畅。码云镜像:https://gitee.com/rector/DncZeus 。演示地址(demo):
Stars: ✭ 1,104 (+1625%)
Mutual labels: netcore
Puppeteer Sharp Extra
Plugin framework for PuppeteerSharp
Stars: ✭ 39 (-39.06%)
Mutual labels: netcore
Razorlight
Template engine based on Microsoft's Razor parsing engine for .NET Core
Stars: ✭ 1,068 (+1568.75%)
Mutual labels: netcore
Cookedrabbit
CookedRabbit is a simple service based RabbitMQ wrapper for dealing with channels/connections.
Stars: ✭ 28 (-56.25%)
Mutual labels: netcore
Lyndacoursesdownloader
Cross platform .net core program to download lynda.com courses for offline use
Stars: ✭ 37 (-42.19%)
Mutual labels: netcore
Aws Lambda Dotnet
Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Stars: ✭ 945 (+1376.56%)
Mutual labels: netcore
Netcore Postgres Oauth Boiler
A basic .NET Core website boilerplate using PostgreSQL for storage, Adminer for db management, Let's Encrypt for SSL certificates and NGINX for routing.
Stars: ✭ 57 (-10.94%)
Mutual labels: netcore
Request.swift
A tiny HTTP client written in swift. URLSession alternative
Stars: ✭ 14 (-78.12%)
Mutual labels: httpclient
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-1.56%)
Mutual labels: netcore
Alphavantage.net
.Net client library for Alpha Vantage API
Stars: ✭ 52 (-18.75%)
Mutual labels: netcore
HttpClientFactory For netcore And framework
NUGET Install-Package HttpClientFactory
supported netcore2.0 and framework4.5+
Why need HttpClientFactory?
As you know, HttpClient has a trap for using!
- if not Singleton, each instance of HttpClient will open a new socket connection and on high traffic sites you can exhaust the available pool and receive a System.Net.Sockets.SocketException
- if Singleton,HttpClient doesn't respect DNS changes!
So how to use HttpClient correctly?
//useage 1: same Host use same HttpClient
PerHostHttpClientFactory perHostHttpClientFactory = new PerHostHttpClientFactory();// can be static
//or you can change default timeout for perFactory
PerHostHttpClientFactory perHostHttpClientFactory = new PerHostHttpClientFactory(TimeSpan.FromSeconds(10));
HttpClient client = perHostHttpClientFactory.GetHttpClient("http://www.baidu.com");
//useage 2: per url use per HttpClient
PerUrlHttpClientFactory perUrlHttpClientFactory = new PerUrlHttpClientFactory();
//or you can change default timeout for perFactory
PerUrlHttpClientFactory perUrlHttpClientFactory = new PerUrlHttpClientFactory(TimeSpan.FromSeconds(10));
HttpClient client = perUrlHttpClientFactory.GetHttpClient("http://www.baidu.com");
//useage 3: per proxy use per HttpClient
PerHostHttpClientFactory perHostHttpClientFactory = new PerHostHttpClientFactory();
//or you can change default timeout for perFactory
PerHostHttpClientFactory perHostHttpClientFactory = new PerHostHttpClientFactory(TimeSpan.FromSeconds(10));
HttpClient client = perUrlHttpClientFactory.GetProxiedHttpClient("http://127.0.0.1:8080");
Easy to implement
public class XXXHttpClientFactory : HttpClientFactoryBase
{
protected override string GetCacheKey(string key)
{
return key;
}
protected override HttpClient CreateHttpClient(HttpMessageHandler handler)
{
return new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(20),
};
}
protected override HttpMessageHandler CreateMessageHandler()
{
var handler = new HttpClientHandler();
handler.Proxy = new WebProxy("xxx");
return handler;
}
}
Remark
- Default Timeout is TimeSpan.FromSeconds(100)
- Default ConnectionLeaseExpired is TimeSpan.FromMinutes(1)
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].