Poilkj19.NetModularity.Http
7.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Poilkj19.NetModularity.Http --version 7.0.1
NuGet\Install-Package Poilkj19.NetModularity.Http -Version 7.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Poilkj19.NetModularity.Http" Version="7.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Poilkj19.NetModularity.Http --version 7.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Poilkj19.NetModularity.Http, 7.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Poilkj19.NetModularity.Http as a Cake Addin #addin nuget:?package=Poilkj19.NetModularity.Http&version=7.0.1 // Install Poilkj19.NetModularity.Http as a Cake Tool #tool nuget:?package=Poilkj19.NetModularity.Http&version=7.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Http 请求模块
1. 介绍
基于 HttpClient 进行的扩展原汁原味的 HttpClient,支持请求重试、请求超时、请求日志、请求缓存、请求拦截等功能。
// 使用示例
clientFactory.CreateClient()
.Send<TResponse>(req =>
{
req.Url(request.GetRequestUrl()).Verb(request.GetRequestMethod());
var queryParams = new Dictionary<string, object> { { "access_token", GetAccessToken(devConfig) } };
if (req.Method == HttpMethod.Get)
{
foreach (var (key, val) in request.BuildRequestParameters()) queryParams.Add(key, val);
}
else
{
// 获取上传文件的参数
var fileParams = request.GetFileParameters();
if (fileParams == null)
{
// 直接JSON请求体
req.JsonBody(request.BuildRequestParameters(), null);
}
else
{
// 以form提交方式
var boundary = DateTime.Now.Ticks.ToString("X");
req.Form(form =>
{
// 请求参数
foreach (var (key, val) in request.BuildRequestParameters())
form.Add(new StringContent(val.ToString(), encoding: null), $"\"{key}\"");
// 文件参数
foreach (var (key, val) in fileParams)
form.Add(new ByteArrayContent(File.ReadAllBytes(val.FullName)), key, val.Name);
}, boundary);
}
}
req.Query(queryParams);
req.OnResponse((res, content, data) =>
{
if (data.ErrCode == (int)DingErrorCode.Success) return;
if (request.OnError != null)
{
request.OnError(data);
return;
}
if (request.IfNotSuccessThrow) throw new Exception($"[钉钉] {data.ErrMsg}");
});
})
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Poilkj19.NetModularity.File (>= 7.0.1)
- Poilkj19.NetModularity.Utilities (>= 7.0.1)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on Poilkj19.NetModularity.Http:
Package | Downloads |
---|---|
Poilkj19.NetModularity.GuanData
观远SDK |
|
Poilkj19.NetModularity.Juhe
聚合SDK |
|
Poilkj19.NetModularity.Moka
摩卡SDK |
|
Poilkj19.NetModularity.KeyFunc
企云方SDK |
|
Poilkj19.NetModularity.DouDian
抖店SDK |
GitHub repositories
This package is not used by any popular GitHub repositories.