Description
Every method in the library creates a disposable HttpClient inside a using block:
using (HttpClient httpClient = new HttpClient())
{
...
}
This is an established .NET anti-pattern. Each construction opens a new socket connection; disposing the client does not immediately release the underlying socket — it enters TIME_WAIT. Under any meaningful load this causes socket exhaustion and SocketException.
References
Recommended Fix
Option A — Static singleton (simple, no DI required for a library):
private static readonly HttpClient _httpClient = new HttpClient();
Option B — Accept IHttpClientFactory or HttpClient as a constructor/method parameter to allow callers to manage the lifetime (better for testability and named clients).
Scope
All five partial-class files: Get.cs, Post.cs, Put.cs, Patch.cs, Delete.cs.
Acceptance Criteria
Description
Every method in the library creates a disposable
HttpClientinside ausingblock:This is an established .NET anti-pattern. Each construction opens a new socket connection; disposing the client does not immediately release the underlying socket — it enters
TIME_WAIT. Under any meaningful load this causes socket exhaustion andSocketException.References
Recommended Fix
Option A — Static singleton (simple, no DI required for a library):
Option B — Accept
IHttpClientFactoryorHttpClientas a constructor/method parameter to allow callers to manage the lifetime (better for testability and named clients).Scope
All five partial-class files:
Get.cs,Post.cs,Put.cs,Patch.cs,Delete.cs.Acceptance Criteria
new HttpClient()inside method bodies