Requests and responses, standard library only.
A fluent builder for HttpRequestMessage and HttpResponseMessage built on System.Net.Http alone, with no dependencies and no wrapper types.
🏃 Getting Started | 📚 Documentation
The builders are extension methods on the types in System.Net.Http, so a
request or response stays a plain HttpRequestMessage or
HttpResponseMessage.
- No dependencies beyond
System.Net.Http - No wrapper types
- Headers, content and version set in one chain
using HttpBuildR;
// alias the method so the chain reads like a sentence
using Req = HttpMethod;
HttpRequestMessage request =
Req.Post
.To("http://some-url/some-part")
.WithBearerToken(token)
.WithAccept("application/json")
.WithHeader("x-custom-header", "a", "b", "c")
.WithJsonContent(new { Name = "John", Age = 36 });The chain builds a request. Sending it is still up to the caller.
| Package | Builds | NuGet |
|---|---|---|
| HttpBuildR.Request | HttpRequestMessage |
nuget |
| HttpBuildR.Response | HttpResponseMessage |
nuget |
| HttpBuildR.ActionResult | HttpResponseMessage from an action result |
nuget |
The test projects in src/Request/HttpBuildR.Request.Tests and
src/Response/HttpBuildR.Response.Tests cover every builder, and are the
closest thing to a reference for edge cases.
Most http libraries wrap System.Net.Http in a client of their own. This one
keeps the core types and only replaces the setup code with a chain, so anything
that already accepts an HttpRequestMessage keeps working.