Linger.HttpClient.Standard
0.4.0-alpha
See the version list below for details.
dotnet add package Linger.HttpClient.Standard --version 0.4.0-alpha
NuGet\Install-Package Linger.HttpClient.Standard -Version 0.4.0-alpha
<PackageReference Include="Linger.HttpClient.Standard" Version="0.4.0-alpha" />
<PackageVersion Include="Linger.HttpClient.Standard" Version="0.4.0-alpha" />
<PackageReference Include="Linger.HttpClient.Standard" />
paket add Linger.HttpClient.Standard --version 0.4.0-alpha
#r "nuget: Linger.HttpClient.Standard, 0.4.0-alpha"
#:package Linger.HttpClient.Standard@0.4.0-alpha
#addin nuget:?package=Linger.HttpClient.Standard&version=0.4.0-alpha&prerelease
#tool nuget:?package=Linger.HttpClient.Standard&version=0.4.0-alpha&prerelease
Linger.HttpClient.Standard
Introduction
Linger.HttpClient.Standard is an implementation based on the standard .NET HttpClient, providing a lightweight wrapper that conforms to the Linger.HttpClient.Contracts interfaces. This project focuses on delivering a stable, efficient, and .NET-style HTTP communication solution.
🔗 This project is part of the Linger HTTP Client Ecosystem.
Core Advantages
- Lightweight Design: Minimal dependencies, low runtime overhead
- .NET Conventions: Naturally integrates with .NET projects, follows platform design principles
- High Performance: Optimized for performance, suitable for high-concurrency scenarios
- Easy Troubleshooting: Transparent implementation, clear error information
- Low Memory Footprint: Optimized memory management, suitable for resource-constrained environments
Recent Improvements
1. Fully Integrated Interceptors
The interceptor system is now fully integrated into StandardHttpClient, ensuring consistent handling of requests and responses:
// Apply request interceptors
request = await ApplyInterceptorsToRequestAsync(request);
// Execute request
var res = await _httpClient.SendAsync(request, combinedToken);
// Apply response interceptors
res = await ApplyInterceptorsToResponseAsync(res);
2. Optimized Retry Logic
Retry logic has been moved to interceptors to avoid duplicate retries:
// Previous retry code has been removed
// var res = await ProcessRequestWithRetriesAsync(...);
// Now retries are handled uniformly by interceptors
var client = new StandardHttpClient("https://api.example.com");
client.Options.EnableRetry = true;
client.Options.MaxRetryCount = 3;
3. Automatic Benefits from StandardHttpClientFactory
When using the factory, you automatically get the benefits of interceptors and configuration:
// Create client with factory
var factory = new StandardHttpClientFactory();
var client = factory.CreateClient("https://api.example.com", options => {
options.EnableRetry = true;
options.DefaultTimeout = 15;
});
// Compression support and retry functionality are automatically included
Installation
dotnet add package Linger.HttpClient.Standard
Quick Start
// Create client
var client = new StandardHttpClient("https://api.example.com");
// Send request
var response = await client.GetAsync<UserData>("api/users/1");
Advanced Features
1. Custom HttpMessageHandler
Full control over the underlying HttpClient behavior:
// Custom handler
var handler = new HttpClientHandler
{
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
UseCookies = false,
MaxConnectionsPerServer = 20
};
// Create client with custom handler
var client = new StandardHttpClient(new System.Net.Http.HttpClient(handler));
2. Integrated HTTP Compression
Use the built-in compression helper class to reduce bandwidth consumption:
// Create compression-enabled handler
var handler = CompressionHelper.CreateCompressionHandler();
// Create client
var client = new StandardHttpClient(new System.Net.Http.HttpClient(handler));
3. Efficient Parallel Requests
// Send multiple requests in parallel
var task1 = client.GetAsync<Data1>("api/endpoint1");
var task2 = client.GetAsync<Data2>("api/endpoint2");
var task3 = client.GetAsync<Data3>("api/endpoint3");
// Wait for all requests to complete
await Task.WhenAll(task1, task2, task3);
// Process all results
var result1 = task1.Result.Data;
var result2 = task2.Result.Data;
var result3 = task3.Result.Data;
Use Cases
StandardHttpClient is particularly well-suited for:
- Performance and resource-sensitive applications: Mobile apps, applications running on low-spec devices
- Projects requiring fine-grained HTTP communication control: Security-sensitive enterprise systems
- Projects migrating from existing .NET HttpClient: Smooth transition, low learning curve
- Applications requiring .NET-specific features: WinForms, WPF, or systems that need integration with .NET-specific APIs
Comparison with FlurlHttpClient
| Scenario | StandardHttpClient | FlurlHttpClient |
|---|---|---|
| Performance requirements | ★★★★★ | ★★★☆☆ |
| Low resource usage | ★★★★★ | ★★★☆☆ |
| URL building capability | ★★☆☆☆ | ★★★★★ |
| API fluency | ★★★☆☆ | ★★★★★ |
| Learning curve | Gentle | Moderate |
| Suitable projects | Enterprise applications, resource-constrained environments | Modern web applications, complex API integrations |
Best Practices
Use HttpClientFactory to manage instances
services.AddSingleton<IHttpClientFactory, StandardHttpClientFactory>();Create named clients grouped by API
factory.RegisterClient("users-api", "https://users.example.com"); factory.RegisterClient("products-api", "https://products.example.com");Performance-oriented configuration
client.Options.DefaultTimeout = 15; // Shorter timeoutUse with CancellationToken
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5)); await client.GetAsync<Data>("api/data", cancellationToken: cts.Token);File Upload Best Practices
// File uploads are now simpler, handled by MultipartHelper var response = await client.CallApi<UploadResult>( "api/upload", HttpMethodEnum.Post, formData, fileBytes, "document.pdf" );
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. net10.0 was computed. 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. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- Linger.HttpClient.Contracts (>= 0.4.0-alpha)
-
net8.0
- Linger.HttpClient.Contracts (>= 0.4.0-alpha)
-
net9.0
- Linger.HttpClient.Contracts (>= 0.4.0-alpha)
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.0.0-preview2 | 0 | 11/6/2025 |
| 1.0.0-preview1 | 33 | 11/5/2025 |
| 0.9.8 | 131 | 10/14/2025 |
| 0.9.7-preview | 119 | 10/13/2025 |
| 0.9.6-preview | 102 | 10/12/2025 |
| 0.9.5 | 105 | 9/28/2025 |
| 0.9.4-preview | 131 | 9/25/2025 |
| 0.9.3-preview | 151 | 9/22/2025 |
| 0.9.1-preview | 257 | 9/16/2025 |
| 0.9.0-preview | 84 | 9/12/2025 |
| 0.8.5-preview | 183 | 8/31/2025 |
| 0.8.4-preview | 301 | 8/25/2025 |
| 0.8.3-preview | 159 | 8/20/2025 |
| 0.8.2-preview | 192 | 8/4/2025 |
| 0.8.1-preview | 114 | 7/30/2025 |
| 0.8.0-preview | 560 | 7/22/2025 |
| 0.7.2 | 178 | 6/3/2025 |
| 0.7.1 | 176 | 5/21/2025 |
| 0.7.0 | 175 | 5/19/2025 |
| 0.6.0-alpha | 185 | 4/28/2025 |
| 0.5.0-alpha | 181 | 4/10/2025 |
| 0.4.0-alpha | 176 | 4/1/2025 |