Stop Tormenting HttpClient! Meet HttpAgent — Redefining .NET HTTP Requests
From the pain points of HttpClient: five code styles, a cURL/JSON parsing engine, built-in resilience and an industrial-grade traffic inspection engine — HttpAgent redefines HTTP requests in .NET.Make every HTTP request transparent.
Every .NET developer has a love-hate memory of HttpClient:
- For every request you rewrite the same boilerplate:
new HttpClient(), URL concatenation, query strings, headers, content types; - One careless
usingaround anew HttpClient()and production runs out of sockets — the moment load testing starts, it dies; - Timeouts, retries, backoff, circuit breaking? Sorry — either hand-roll them or pull in the whole Polly kit;
- A colleague drops a curl one-liner on you "to reproduce" and you translate it line by line into C#, then debug your translation;
- Want to see what was actually sent and received? Open Fiddler, configure proxies, install certificates, filter traffic — half an hour of setup for five minutes of debugging;
- File uploads and downloads, progress bars, SSE, long polling, WebSocket, SOAP, OData, token auto-refresh… each one is another wheel to reinvent.
In the end you realize: the hard part was never "sending a request" — it's doing it right, doing it completely, and keeping it maintainable.
Today's protagonist is here to end that suffering — HttpAgent.
Meet HttpAgent in one sentence
HttpAgent is a high-performance, flexible and easy-to-use .NET HTTP open-source library built around one core idea: make every HTTP request transparent.
A few numbers that are hard to say no to:
- Zero third-party dependencies: one NuGet package, ready to go — no Polly, no Flurl, nothing;
- All platforms: Console / Web / WASM / WinForms / WPF / MAUI, all on .NET 8+;
- Industrial-grade quality: 98% test coverage, every release passes strict regression verification;
- Full feature toolkit: retries, timeouts, circuit breaking, quotas, ETag caching, automatic Access Token management… all built in.
Five styles, your choice
HttpAgent's most addictive design decision: it splits "sending a request" into five styles. Pick whichever you like — mixing them in one project feels perfectly natural.
Style one: verb methods, one-liners
// Fetch a website with one linevar content = await httpRemoteService.GetAsStringAsync("https://api.example.com/");// Generic overload returns strongly-typed resultsvar user = await httpRemoteService.GetAsAsync<User>("https://api.example.com/user/1");Style two: the builder, chain it up
var result = await httpRemoteService.SendAsync<string>( HttpRequestBuilder.Post("https://api.example.com/login") .SetJsonContent(new { account = "admin", password = "123456" }) .SetTimeout(TimeSpan.FromSeconds(30)) .Profiler()); // Turn on the request profilerStyle three: declarative requests, interface = API
public interface IUserApi : IHttpDeclarative{ [Get("https://api.example.com/user/{id}")] Task<User> GetUserAsync(int id); [Post("https://api.example.com/user"), Profiler] Task<User> CreateUserAsync([Body] User user);}Register it, inject it, and calling a remote API feels like calling a local method. Path templates, query parameters, request bodies, forms, multipart uploads — all declared with attributes. The code is absurdly clean.
services.AddHttpRemote(builder =>{ builder.AddHttpDeclarative<IUserApi>();});Style four: send from cURL, paste and go
You've been there: the third-party docs contain nothing but a curl command. Support sends it, QA sends it, even your boss sends it: "Just do it like this."
You used to translate that curl into C# character by character. Now:
var result = await httpRemoteService.SendAsStringAsync( HttpRequestBuilder.FromCurl(""" curl -k -X POST 'https://api.example.com/order?query1=10&query2=hello' \ -H 'Content-Type: application/json' \ -d '{ "id": 1, "name": "sample" }' """));HttpAgent ships a built-in cURL parsing engine supporting -X, -H, -d, -F, -u, --data-urlencode, --max-time, --http2 and more — file uploads, URL-encoded forms, Basic auth, plus custom flags you can extend yourself.
Paste the cURL in, let the engine take over. Friendly to humans, and extremely friendly to AI — the curl commands an AI outputs no longer need manual translation into code.
Style five: send from JSON, config is the request
If chained calls still feel verbose, write the request as JSON:
var result = await httpRemoteService.SendAsStringAsync( HttpRequestBuilder.FromJson(""" { "url": "https://api.example.com/order", "method": "POST", "queries": { "page": 1, "size": 10 }, "headers": { "Content-Type": "application/json" }, "auth": { "type": "bearer", "token": "xxx" }, "timeout": 5000, "data": { "id": 1, "name": "sample" } } """));URL, base address, query parameters, headers, cookies, timeout, authentication (Bearer / Basic / Digest), body, multipart uploads, profiler switch — everything is JSON. Request configs can live in databases, configuration files, or even be generated by AI on the fly.
One package, the entire HTTP engineering toolkit
Many "lightweight" HTTP libraries are so light you end up rebuilding everything yourself. HttpAgent goes the opposite way: one package with everything HTTP engineering needs built in — and zero third-party dependencies.
- Resilience & fault tolerance: retries, exponential backoff, timeouts, circuit breaking and fallback — one
SetRetrycall spins up a full resilience strategy; - Automatic Access Token management: fetch automatically, refresh on expiry, retry on
401, inject into Header / Query / Cookie wherever you configure it — no more hand-written token timers when integrating with third-party platforms; - Quotas & ETag caching: daily / weekly / monthly / lifetime call-quota windows and
304cache reuse — save bandwidth and prevent overruns; - Real-time communication: SSE, long polling, WebSocket and
IAsyncEnumerable<T>streaming responses, all included; - File transfer: upload/download, multi-threaded chunked downloads, progress callbacks, console progress bars, automatic RFC 2047 / RFC 5987 filename decoding;
- Gateway & proxying: one-line
HttpContextforwarding with built-in gateway capability; - Testing & debugging: request/response assertions, Mock testing, stress testing — built in;
- Every data format: JSON, JSON Lines, MessagePack, XML, HTML, SOAP (WebService) and OData;
- Automatic decompression: gzip / deflate / brotli / zstd responses decompressed for you.
One example — a single line for "smart retry with exponential backoff":
HttpRequestBuilder.Get("https://api.example.com/order/1") .SetRetry(options => options .SetMaxRetries(3) .SetUseExponentialBackoff(true) .AddRetryStatusCodes(408, 429, 500, 502, 503, 504));Industrial-grade traffic inspection: black box to white box
What hurts most when debugging third-party APIs? You can't see.
Which headers were really sent? Is the body encoded correctly? Why is the response empty?
HttpAgent has a built-in industrial-grade HTTP traffic inspection engine (Profiler). Append .Profiler() to any request and the console prints the complete, color-highlighted request and response:
await httpRemoteService.GetAsync("https://api.example.com/order/1", builder => builder.Profiler());Method, full URL, all request headers, body, status code, response headers, response body, elapsed time… everything at a glance. Half an hour of packet capture becomes one line of code.
The most AI-friendly .NET HTTP library
In 2026, AI-assisted coding is the daily routine. HttpAgent may well be the most AI-friendly .NET HTTP library:
- Native llms.txt support: the official docs ship
llms.txtandllms-full.txt(in both Chinese and English) so AI assistants like Claude Code and Codex can read the entire documentation in one pass — no page-by-page scraping. Dropllms-full.txtinto your project'sCLAUDE.md/AGENTS.mdand AI-generated HttpAgent code just works. - Declarative interfaces are an AI playground: give the AI an interface definition and it will reliably generate a complete, attribute-annotated API client — highly readable, minimal review cost.
- cURL / JSON as code: the curl commands and JSON configs an AI produces paste directly into runnable requests — zero translation cost.
Up and running in three steps
# 1. Install (any .NET 8+ app)dotnet add package HttpAgent# Web apps additionally get HttpContext forwardingdotnet add package HttpAgent.AspNetCore// 2. Register the servicebuilder.Services.AddHttpRemote();// 3. Govar user = await httpRemoteService.GetAsAsync<User>("https://api.example.com/user/1");From install to first request in under three minutes.
Finally
If you've ever wrestled with a curl command late at night, chased HttpClient socket exhaustion in production, or stacked three thousand lines of wrapper code around "a simple request feature" —
give HttpAgent a chance. And give yourself one too.
- Repository (GitHub): https://github.com/monksoul/HttpAgent
- NuGet: https://www.nuget.org/packages/HttpAgent
Make every HTTP request transparent.