🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

Soenneker.Extensions.HttpClient

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Soenneker.Extensions.HttpClient

A collection of helpful HttpClient extension methods, like retry and auto (de)serialization

3.0.3349
Source
NuGet
Version published
Maintainers
1
Created
Source

Soenneker.Extensions.HttpClient

A collection of helpful HttpClient extension methods, like retry and auto (de)serialization

Installation

dotnet add package Soenneker.Extensions.HttpClient

SendToString()

var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/data");
var responseContent = await _httpClient.SendToString(request);

SendWithError()

var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/data");
MySuccessResponse? successResponse, MyErrorResponse? errorResponse = await _httpClient.SendWithError<MySuccessResponse, MyErrorResponse>(request);

TrySend()

var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/data");
bool successful, HttpResponseMessage? response = await _httpClient.TrySend(request);

SendWithRetryToType()

var requestData = new { Name = "John Doe" };
var response = await _httpClient.SendWithRetryToType<MyResponseType>(
    HttpMethod.Post,                 // HTTP Method
    "https://api.example.com/data",   // URI
    requestData,                     // Request body
    numberOfRetries: 3,              // Retry 3 times
    logger: _logger,                 // Optional logger
    baseDelay: TimeSpan.FromSeconds(2), // Exponential backoff
    log: true,                       // Enable logging
    cancellationToken: cancellationToken // Cancellation token
);

... and more

Keywords

extensions

FAQs

Package last updated on 16 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts