fm.Extensions.HttpClient
8.0.0
dotnet add package fm.Extensions.HttpClient --version 8.0.0
NuGet\Install-Package fm.Extensions.HttpClient -Version 8.0.0
<PackageReference Include="fm.Extensions.HttpClient" Version="8.0.0" />
<PackageVersion Include="fm.Extensions.HttpClient" Version="8.0.0" />
<PackageReference Include="fm.Extensions.HttpClient" />
paket add fm.Extensions.HttpClient --version 8.0.0
#r "nuget: fm.Extensions.HttpClient, 8.0.0"
#:package fm.Extensions.HttpClient@8.0.0
#addin nuget:?package=fm.Extensions.HttpClient&version=8.0.0
#tool nuget:?package=fm.Extensions.HttpClient&version=8.0.0
Extensions for System.Net.Http (especially HttpClient).
Provides convenient methods like GetVerified, PostVerified, PostAsJsonVerified and more which take care of error handling for you.
Also supports RFC 7807 (Problem Details).
Examples
HttpLogger (with content logging)
services
.Configure<HttpLoggerOptions>("HttpClient.Default", this.Configuration.GetSection("HttpClient:Default"))
.PostConfigure<HttpLoggerOptions>("HttpClient.Default", o =>
{
o.LogContent = true;
o.MaxTextLength = 15;
o.MaxContentBytes = 100;
//o.ContentFormatter = c => c.ReadAsStringAsync().GetAwaiter().GetResult();
});
services.AddHttpClient("HttpClient.Default")
.ConfigurePrimaryHttpMessageHandler<MockHttpMessageHandler>()
.UseHttpLogger();
Results in the following log message.
HttpClient.Default[200]: Information: POST https://localhost/Lorem -> OK (200); 2ms
Request (text/plain; charset=utf-8): Test Request content.
Response (text/plain; charset=utf-8): Lorem ip...g elit. [TRUNCATED 15/56 characters]
Main Types
The main types provided by this library are:
HttpClientExtensionsGetVerifiedGetWithResultPostVerifiedPostAsJsonVerifiedPostWithResultPostAsJsonWithResult- and more for
Put,PatchandDelete
HttpResponseHandlerHttpErrorResponseHandlerHttpLoggingHandlerHttpLoggingHandlerOptionsHttpResponseExceptionHttpStatusCodeExceptionProblemDetailsProblemDetailsHandlerMediaType
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Added `HttpLoggerOptions.MaxTextLength`
- Added `HttpLoggerOptions.MaxContentBytes`
- BREAKING: HttpLoggerOptions.ContentFormatter changed to `Func<HttpContent, string>`
- BREAKING: The default `ContentFormatter` is now much smarter.