Cs.HttpClient
0.0.3
See the version list below for details.
dotnet add package Cs.HttpClient --version 0.0.3
NuGet\Install-Package Cs.HttpClient -Version 0.0.3
<PackageReference Include="Cs.HttpClient" Version="0.0.3" />
paket add Cs.HttpClient --version 0.0.3
#r "nuget: Cs.HttpClient, 0.0.3"
// Install Cs.HttpClient as a Cake Addin #addin nuget:?package=Cs.HttpClient&version=0.0.3 // Install Cs.HttpClient as a Cake Tool #tool nuget:?package=Cs.HttpClient&version=0.0.3
Cs.HttpClient
This project gathers logic related to handling HTTP requests required for using external REST APIs. In C#, there are several interfaces like HttpRequest, WebClient, and HttpClient for processing HTTP requests. Although HttpClient is the most current form, caution is necessary when using it.
Generally, for lightweight requests with low load, there are no issues. However, when multiple threads aim to handle a massive throughput momentarily, performance problems might arise. Below are links to documents related to this matter for further reference.
C#에서 외부 rest api를 사용하기 위해 필요한 http request 처리에 관한 로직들을 모았습니다. C#으로 http 요청을 처리하는 데에는 HttpRequest, WebClient, HttpClient등 많은 인터페이스가 있습니다. 가장 최종적인 형태는 HttpClient이지만, 사용시에 주의가 필요합니다.
일반적으로 부하가 크지 않은 가벼운 요청의 경우는 아무런 문제가 없지만, 다수의 스레드가 순간적으로 대량의 throughput을 처리하고자 할 땐 성능 문제가 발생할 수 있습니다. 이와 관련된 문서들의 링크를 아래에 정리했으니 참고 바랍니다.
Getting Started
Usage
using Cs.HttpClient;
using Cs.Logging;
var apiClient = new RestApiClient("Https://slack.com/api/");
var parameters = new Dictioary<string, string>
{
{ "token", endpoint.Token },
// ... fill parameters
}
var content = new FormUrlEncodedContent(parameters);
var response = await apiClient.PostAsync("files.upload", content);
if (response.IsSuccessStatusCode == false)
{
Log.Error($"files.upload failed. response:{response}");
return;
}
Log.Info($"uploading file succeed. responseCode:{response.StatusCode}");
Contact
mailto: github@studiobside.com
See Also
- https://makolyte.com/csharp-how-to-make-concurrent-requests-with-httpclient/
- https://hwanstory.kr/@kim-hwan/posts/DotNet-HttpConnectionPooling
- https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
- https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory#httpclient-lifetime-management
- https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Cs.Core (>= 0.0.3)
- Cs.Logging (>= 0.0.3)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
first release