mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Address code review feedback
- Replace GetAwaiter().GetResult() with synchronous ReadAsStream() - Use JsonNode.DeepClone() instead of serialize/parse round-trip - Extract timeout magic number to named constant Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> Agent-Logs-Url: https://github.com/milutinke/Minecraft-Console-Client/sessions/afcd1b7b-ea23-4a0d-bb46-a90b623406fc
This commit is contained in:
parent
37fe626325
commit
64ccdcb39b
2 changed files with 7 additions and 3 deletions
|
|
@ -13,6 +13,8 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
public class ProxiedWebRequest
|
||||
{
|
||||
private const int DefaultConnectTimeoutSeconds = 30;
|
||||
|
||||
private readonly Uri _uri;
|
||||
|
||||
public NameValueCollection Headers { get; } = new();
|
||||
|
|
@ -113,7 +115,9 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
using var httpResponse = client.Send(request);
|
||||
string responseBody = httpResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
using var stream = httpResponse.Content.ReadAsStream();
|
||||
using var reader = new System.IO.StreamReader(stream);
|
||||
string responseBody = reader.ReadToEnd();
|
||||
|
||||
var responseHeaders = new NameValueCollection();
|
||||
foreach (var header in httpResponse.Headers)
|
||||
|
|
@ -150,7 +154,7 @@ namespace MinecraftClient.Protocol
|
|||
UseCookies = true,
|
||||
CookieContainer = new CookieContainer(),
|
||||
AllowAutoRedirect = false,
|
||||
ConnectTimeout = TimeSpan.FromSeconds(30),
|
||||
ConnectTimeout = TimeSpan.FromSeconds(DefaultConnectTimeoutSeconds),
|
||||
};
|
||||
|
||||
if (ProxyHandler.Config.Enabled_Login)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue