![]() |
VOOZH | about |
Requires NuGet 5.0.0 or higher.
dotnet add package Genocs.Http --version 9.0.0
NuGet\Install-Package Genocs.Http -Version 9.0.0
<PackageReference Include="Genocs.Http" Version="9.0.0" />
<PackageVersion Include="Genocs.Http" Version="9.0.0" />Directory.Packages.props
<PackageReference Include="Genocs.Http" />Project file
paket add Genocs.Http --version 9.0.0
#r "nuget: Genocs.Http, 9.0.0"
#:package Genocs.Http@9.0.0
#addin nuget:?package=Genocs.Http&version=9.0.0Install as a Cake Addin
#tool nuget:?package=Genocs.Http&version=9.0.0Install as a Cake Tool
Http client abstractions and helpers for Genocs applications. Supports net10.0, net9.0, and net8.0.
dotnet add package Genocs.Http
Use this package to provide the base Http abstraction layer for outbound service calls and client configuration in Genocs services. Registration flows through Genocs.Core (IGenocsBuilder.AddHttpClient(...)).
AddHttpClient — registers a typed IHttpClient (GenocsHttpClient), HttpClientOptions, and the default SystemTextJsonHttpClientSerializer. Use the optional httpClientBuilder argument to call ConfigureHttpClient (for example to set HttpClient.BaseAddress for relative URI strings).httpClient)AddHttpClient(...) binds HttpClientOptions from the httpClient section.
{
"httpClient": {
"enabled": true,
"type": "consul",
"retries": 3,
"retryUnsafeHttpMethods": false,
"services": {
"orders": "http://orders-service"
},
"removeCharsetFromContentType": true,
"correlationContextHeader": "x-correlation-context",
"correlationIdHeader": "x-correlation-id",
"requestMasking": {
"enabled": true,
"urlParts": ["token", "password"],
"maskTemplate": "*****"
}
}
}
Fields actively used by this package runtime:
retriesretryUnsafeHttpMethodsremoveCharsetFromContentTypecorrelationContextHeadercorrelationIdHeaderrequestMasking.enabledrequestMasking.urlPartsrequestMasking.maskTemplateFields currently present in the options contract but not implemented by this package runtime:
enabledtypeservicesTreat those fields as shared configuration shape unless a companion package documents concrete runtime behavior.
GetAsync, PostAsync, GetAsync<T>, PostAsync<T>, and similar either return HttpResponseMessage after a successful status or throw when the status is not successful (typed methods deserialize only after success).*ResultAsync<T>(string, ...) (for example GetResultAsync<T>, PostResultAsync<T>) return HttpResult<T> for both success and failure status codes. Inspect HttpResult<T>.Response for status and content; they do not throw solely because the HTTP status indicates an error. For non-success responses, Result is typically the default value for T; use HasResult only as a hint about a non-null deserialized payload.HttpRequestMessage overloads — SendResultAsync<T>(HttpRequestMessage, ...) preserves non-success responses in HttpResult<T>. SendAsync<T>(HttpRequestMessage, ...) throws when the status is not successful (exception-oriented deserialization path). Request-message overloads send the provided HttpRequestMessage once per call and do not internally retry by replaying that instance.T? consume and dispose transient HttpResponseMessage instances internally. Methods that return HttpResponseMessage or HttpResult<T> transfer response ownership to the caller.HttpRequestException without a response status, retryable HttpRequestException status codes, and IOException).HttpRequestMessage overloads intentionally do not replay the same message instance.OperationCanceledException / TaskCanceledException.POST, PUT, and PATCH are excluded unless explicitly enabled.httpClient.retries and opt-in write-method retries via httpClient.retryUnsafeHttpMethods in HttpClientOptions.HttpClient.DefaultRequestHeaders.ICorrelationContextFactory and ICorrelationIdFactory.HttpRequestMessage, Genocs.Http preserves those values and does not overwrite them.StringComparison.Ordinal) over the URI text rendered for logging (HttpRequestMessage.RequestUri.OriginalString).Uri.BaseAddressRequest URI strings are parsed with System.Uri (UriKind.RelativeOrAbsolute) after trimming. Null, whitespace-only, or unparseable values throw ArgumentException with parameter name uri.
Pass absolute URIs (for example https://api.contoso.com/v1/items) when you want a fully qualified destination; they are sent unchanged (no scheme or host rewriting).
Pass relative paths (for example items/5 or /items/5) when the named HttpClient has a BaseAddress set, for example:
AddHttpClient(..., httpClientBuilder: b => b.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.contoso.com/v1/")))
Resolution follows normal HttpClient / Uri combination rules. Prefer a BaseAddress that ends with / when you want relative segments to append as subpaths predictably.
The client does not prepend http:// or guess a scheme for host-like strings. Upgrade note: older versions prepended http:// when the string did not start with http; that behavior was removed. Use an absolute URI, or set BaseAddress and pass relative paths.
If you use a relative URI without BaseAddress, HttpClient fails when sending (for example InvalidOperationException); configure the base address explicitly rather than relying on implicit rewriting.
BaseAddress for relative request pathsusing Genocs.Core.Builders;
using Genocs.Http;
IGenocsBuilder genocs = builder.AddGenocs()
.AddHttpClient(httpClientBuilder: b =>
b.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://catalog.internal/api/v1/")));
using System.Text.Json;
using Genocs.Http;
builder.Services.AddSingleton<IHttpClientSerializer>(
new SystemTextJsonHttpClientSerializer(
new JsonSerializerOptions(JsonSerializerDefaults.Web)
{
PropertyNameCaseInsensitive = true
}));
using Genocs.Core.Builders;
using Genocs.Http;
builder.Services.AddSingleton<ICorrelationIdFactory, MyCorrelationIdFactory>();
builder.Services.AddSingleton<ICorrelationContextFactory, MyCorrelationContextFactory>();
IGenocsBuilder genocs = builder.AddGenocs()
.AddHttpClient(maskedRequestUrlParts: ["token", "password"]);
Masking applies only to HTTP-client URL log rendering, not to payloads or arbitrary log properties.
IHttpClientBuilder resilience handlers (for example retry/timeout/circuit-breaker), evaluate the combined strategy to avoid duplicate retry amplification.HttpRequestMessage overloads are single-send by design; if replay behavior is required, implement replay-safe resilience at the handler/pipeline layer.When upgrading from older Genocs.Http behavior, review these consumer-visible changes:
*ResultAsync<T>(...) methods preserve non-success responses in HttpResult<T> instead of throwing solely for status.System.Uri rules only; there is no implicit http:// prefixing.POST/PUT/PATCH require explicit opt-in via httpClient.retryUnsafeHttpMethods=true.HttpRequestMessage overloads are single-send and do not replay the same request instance.For a source-blind upgrade checklist and decision guidance, see Genocs.Http-Agent-Documentation.md.
dotnet build src/Genocs.Http/Genocs.Http.csproj -c Debug --nologo
dotnet test src/tests/Genocs.Http.UnitTests/Genocs.Http.UnitTests.csproj -c Debug --nologo
Genocs.Http applies package-level quality gates in Genocs.Http.csproj to reduce contract regressions:
WarningsAsErrors includes nullable)CodeAnalysisTreatWarningsAsErrors=true)This gate is intentionally package-scoped (not repository-wide) so maintainers can harden outbound HTTP public-surface behavior without forcing unrelated projects to adopt the same baseline immediately.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on Genocs.Http:
| Package | Downloads |
|---|---|
|
Genocs.Discovery.Consul
Consul-based service discovery integration for Genocs applications. |
|
|
Genocs.ServiceDiscovery.Consul
Consul-based service discovery integration for Genocs applications. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 169 | 5/21/2026 |
| 9.0.0-beta009 | 180 | 5/11/2026 |
| 9.0.0-beta008 | 209 | 5/2/2026 |
| 9.0.0-beta007 | 171 | 4/29/2026 |
| 9.0.0-beta006 | 155 | 4/27/2026 |
| 9.0.0-beta005 | 168 | 4/26/2026 |
| 9.0.0-beta004 | 161 | 4/18/2026 |
| 9.0.0-beta003 | 186 | 4/5/2026 |
| 9.0.0-beta002 | 212 | 3/17/2026 |
| 9.0.0-beta001 | 189 | 2/28/2026 |
| 8.1.0 | 236 | 2/8/2026 |
| 8.0.0 | 2,691 | 11/23/2025 |
| 7.5.1 | 2,721 | 10/19/2025 |
| 7.5.0 | 5,413 | 10/12/2025 |
| 7.4.1 | 2,109 | 9/19/2025 |
| 7.4.0 | 385 | 9/19/2025 |
| 7.3.0 | 8,461 | 8/14/2025 |
| 7.2.5 | 13,785 | 5/1/2025 |
| 7.2.4 | 2,287 | 4/18/2025 |
| 7.2.3 | 17,341 | 1/20/2025 |
The change log and breaking changes are listed here.
https://github.com/Genocs/genocs-library/releases