Quiron.HttpClient
1.4.17
dotnet add package Quiron.HttpClient --version 1.4.17
NuGet\Install-Package Quiron.HttpClient -Version 1.4.17
<PackageReference Include="Quiron.HttpClient" Version="1.4.17" />
<PackageVersion Include="Quiron.HttpClient" Version="1.4.17" />
<PackageReference Include="Quiron.HttpClient" />
paket add Quiron.HttpClient --version 1.4.17
#r "nuget: Quiron.HttpClient, 1.4.17"
#:package Quiron.HttpClient@1.4.17
#addin nuget:?package=Quiron.HttpClient&version=1.4.17
#tool nuget:?package=Quiron.HttpClient&version=1.4.17
What is the Quiron.HttpClient?
Project created to group endpoint call methods to facilitate the development and consumption of APIs
Give a Star! ⭐
If you find this project useful, please give it a star! It helps us grow and improve the community.
Namespaces and Dependencies
- ✅ Quiron.HttpClient
- ✅ Newtonsoft.Json
- ✅ System.Net.Http
- ✅ Polly
- ✅ Polly.Extensions.Http
Protected Properties
protected const string _CERTIFICATE_HEADER = "X-Certificate";
protected const string _CLIENT_ID_HEADER = "X-Client-Id";
protected const string _CLIENT_SECRET_HEADER = "X-Client-Secret";
protected virtual string BaseDomain => string.Empty; // you need to implement your base domain here ⚠️
protected virtual int Timeout => 50;
protected virtual Dictionary<string, string> Headers => new() {
{ "Accept", "application/json" },
{ "Accept-Encoding", "gzip,deflate,br" },
{ "Connection", "keep-alive" }
};
Policies
public static IAsyncPolicy<HttpResponseMessage> RetryPolicy(ILogger? logger = null) =>
HttpPolicyExtensions
.HandleTransientHttpError()
.WaitAndRetryAsync(
retryCount: 5,
sleepDurationProvider: retryAttempt => TimeSpan.FromMilliseconds(500 * Math.Pow(2, retryAttempt)),
onRetry: (outcome, timespan, retryAttempt, context) =>
{
if (logger is null) return;
logger.LogWarning("Retry {RetryAttempt} after {Delay}ms to {Url}",
retryAttempt, timespan.TotalMilliseconds, outcome.Result?.RequestMessage?.RequestUri);
}
);
public static IAsyncPolicy<HttpResponseMessage> TimeoutPolicy =>
Policy.TimeoutAsync<HttpResponseMessage>(25);
public static IAsyncPolicy<HttpResponseMessage> CircuitBreakerPolicy =>
HttpPolicyExtensions
.HandleTransientHttpError()
.CircuitBreakerAsync(
handledEventsAllowedBeforeBreaking: 5,
durationOfBreak: TimeSpan.FromSeconds(25);
public static IAsyncPolicy<HttpResponseMessage> ResiliencePolicy(ILogger? logger = null) =>
Policy.WrapAsync(
RetryPolicy(logger),
TimeoutPolicy,
CircuitBreakerPolicy
);
⚠️ IMPORTANT: You can use the policies separately, but use the ResiliencePolicy which already includes the following policies in the correct order: RetryPolicy, TimeoutPolicy and CircuitBreakerPolicy.
Your Program.cs
services.AddHttpClient<IHttpApi, HttpApi>()
.ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler { MaxConnectionsPerServer = 20, AllowAutoRedirect = true };
})
.AddPolicyHandler((serviceProvider, request) =>
{
var logger = serviceProvider.GetRequiredService<ILogger<HttpApi>>();
return PollyPolicies.ResiliencePolicy(logger);
});
Methods
Task<(byte[] content, string contentType)> DownloadAsync<T>(HttpMethod method, string endPoint, object? obj = null, string? token = "");
Task<(byte[] content, string contentType)> DownloadAsync<T>(string endPoint, string? token = "");
Task<T?> GetObjectAsync<T>(string endPoint, string token);
Task<T?> PostObjectAsync<T>(string endPoint, object obj, string token = "");
Task<T?> PutObjectAsync<T>(string endPoint, object obj, string token);
Task<T?> PatchObjectAsync<T>(string endPoint, object obj, string token);
Supports:
- ✅ .NET Standard 2.1
- ✅ .NET 10 through 9 (including latest versions)
- ⚠️ Legacy support for .NET Core 3.1 and older (with limitations)
About
Quiron.HttpClient was developed by EliasRMJ under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Http.Polly (>= 10.0.2)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.4.17 | 193 | 2/7/2026 |
| 1.4.16 | 108 | 2/6/2026 |
| 1.4.15 | 106 | 2/6/2026 |
| 1.4.14 | 195 | 1/20/2026 |
| 1.4.13 | 126 | 1/17/2026 |
| 1.4.12 | 114 | 1/16/2026 |
| 1.4.11 | 137 | 1/5/2026 |
| 1.4.10 | 125 | 1/4/2026 |
| 1.3.12-rc | 114 | 1/3/2026 |
| 1.3.11-rc | 114 | 1/3/2026 |
| 1.2.27 | 361 | 7/9/2025 |
| 1.2.26 | 194 | 7/9/2025 |
| 1.2.25 | 194 | 7/9/2025 |
| 1.2.24 | 199 | 7/8/2025 |
| 1.2.23 | 196 | 7/8/2025 |
| 1.2.22 | 210 | 7/3/2025 |
| 1.2.21 | 348 | 5/15/2025 |
| 1.2.20 | 273 | 5/15/2025 |
| 1.2.15 | 287 | 5/15/2025 |
| 1.2.7 | 292 | 5/15/2025 |
Three more 'Policies' have been added to improve the performance of HttpResponseMessage. These are: TimeoutPolicy, CircuitBreakerPolicy, and ResiliencePolicy. The ResiliencePolicy includes the following policies: RetryPolicy, TimeoutPolicy, and CircuitBreakerPolicy.