Cs.HttpClient 0.0.4

dotnet add package Cs.HttpClient --version 0.0.4
NuGet\Install-Package Cs.HttpClient -Version 0.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cs.HttpClient" Version="0.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cs.HttpClient --version 0.0.4
#r "nuget: Cs.HttpClient, 0.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cs.HttpClient as a Cake Addin
#addin nuget:?package=Cs.HttpClient&version=0.0.4

// Install Cs.HttpClient as a Cake Tool
#tool nuget:?package=Cs.HttpClient&version=0.0.4

.NET publish nuget

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

Version History

v0.0.4
  • 단위 테스트 추가. GetStringAsync() 동작상태 확인
  • MacOS에서 동작하지 않는 현상 수정. DotNetHost.cs에 있던 윈도우 전용 조건 삭제.
  • Cs.Logging 종속성 참조가 0.0.22로 잡히도록 조정.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.4 166 12/24/2023
0.0.3 111 12/19/2023
0.0.2 91 12/19/2023
0.0.1 93 12/14/2023

first release