mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
refine sample http client usage
Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/9bf31c0e-e47b-4654-be10-6ea50f27a581
This commit is contained in:
parent
802cc696d6
commit
c9f1f88e62
1 changed files with 4 additions and 4 deletions
|
|
@ -5,18 +5,18 @@ MCC.LogToConsole(mojangStatus);
|
|||
|
||||
//MCCScript Extensions
|
||||
|
||||
private static readonly System.Net.Http.HttpClient s_httpClient = new();
|
||||
|
||||
string PerformHttpRequest(string uri)
|
||||
{
|
||||
using var httpClient = new System.Net.Http.HttpClient();
|
||||
return httpClient.GetStringAsync(uri).GetAwaiter().GetResult();
|
||||
return s_httpClient.GetStringAsync(uri).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
void SendHttpPostAsync(string uri, string text)
|
||||
{
|
||||
new Thread(() => {
|
||||
using var httpClient = new System.Net.Http.HttpClient();
|
||||
using var content = new System.Net.Http.StringContent(text, System.Text.Encoding.UTF8, "text/plain");
|
||||
using var response = httpClient.PostAsync(uri, content).GetAwaiter().GetResult();
|
||||
using var response = s_httpClient.PostAsync(uri, content).GetAwaiter().GetResult();
|
||||
string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
//LogToConsole(responseString);
|
||||
}).Start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue