https://github.com/pimbrouwers/httipi
💻 Makes HTTP requests a little simpler and (maybe) faster.
https://github.com/pimbrouwers/httipi
api http http-requests json
Last synced: about 1 year ago
JSON representation
💻 Makes HTTP requests a little simpler and (maybe) faster.
- Host: GitHub
- URL: https://github.com/pimbrouwers/httipi
- Owner: pimbrouwers
- License: gpl-3.0
- Created: 2017-08-23T21:16:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-08T13:40:38.000Z (over 7 years ago)
- Last Synced: 2025-03-03T19:51:25.205Z (about 1 year ago)
- Topics: api, http, http-requests, json
- Language: C#
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httipi
A .NET Standard compliant set of extenions methods for `System.Net.HttpClient` that makes making HTTP requests much much simpler. Includes a fluent `HttpRequestMessage` builder.
Compression is automatically enabled if available (from response headers) and streams are used throughout the stack to ensure large requests are handled appropriately.

[](https://travis-ci.org/pimbrouwers/httipi)
## Getting Started
A simple example to execute a `GET` request deserializing JSON to CLR object using [Json.NET](https://github.com/JamesNK/Newtonsoft.Json)
```csharp
var http = new HttpClient();
var someObject = JsonConvert.DeserializeObject(await http.GetString("http://someurl.com"));
```
A more complex `PATCH` request with a JSON request body and an HMAC authorization header.
```csharp
var http = new HttpClient();
string json = JsonConvert.SerializeObject(new { someProperty = "newPropertyValue" });
var req = new HTTipiRequestBuilder().SetUrl("http://someurl.com")
.SetMethod(new HttpMethod("PATCH"))
.WithContent(new StringContent(json, Encoding.UTF8, "application/json"))
.AddHeader("Authorization", "hmac somecrazylonghmackey")
await http.Execute(req);
```
Exception handling.
```csharp
var http = new HttpClient();
try
{
var someObject = JsonConvert.DeserializeObject(await http.GetString("http://someurl.com"));
}
catch (HTTipiException ex)
{
//logging
}
```