Simple wrapper around System.Net.Http.HttpClient
Rightek.HttpClient has no dependency to JSON.net and uses the new built-in JSON api from Microsoft,
System.Text.Json. this new JSON api is powerfull and fast, that's why Rightek.HttpClient doesn't provide any way to use another JSON serializer.
public class WhatTypeOfMusicDoYouLove
{
public string answer { get; set; }
}var uri = "https://dl.dropboxusercontent.com/s/pqm5s3kx64q03fc/Rightek.HttpClient.json";
var res = await Client.Instance
.Init()
.WithUri(uri)
.GetAsync<WhatTypeOfMusicDoYouLove>();
if (res.IsSuccessful)
{
var answer = res.Response.answer;
// answer should be "Trance Music"
}
else
{
// why you looking at me? it's not Rightek.HttpClient's fault
}PM> Install-Package Rightek.HttpClient
Init: Initial HttpClient, here you can configure the proxyWithUri: Request uriWithBasicAuth: Basic authentication modeWithBearerToken: Bearer token authentication modeWithTimeout: Request timeoutWithCookie: Request cookieWithCookies: Request cookiesWithHeader: Request headerWithHeaders: Request headersBeforeCall: Before request callbackAfterCall: After request callbackOnError: Error callbackConfigure: You can use this method instead of all above methods and set all configs at onceSetDefault: You should call it once at application startup, default setting can be override using above methods
DownloadAsync: Download fileUploadAsync: Upload fileUploadAsync<T>: Upload fileGetAsync: Get http requestGetAsync<T>: Get http requestPostFormAsync: Post http requestPostXmlAsync: Post http requestPostByteArrayAsync: Post http requestPostJsonAsync: Post http requestPostAsync: Post http request (No data, JSON, XML, Form, Byte Array)PostFormAsync<T>: Post http requestPostXmlAsync<T>: Post http requestPostByteArrayAsync<T>: Post http requestPostJsonAsync<T>: Post http requestPostAsync<T>: Post http request (No data, JSON, XML, Form, Byte Array)
MIT
Made with ♥ by people @ Rightek