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:
copilot-swe-agent[bot] 2026-03-22 16:46:33 +00:00
parent 37fe626325
commit 64ccdcb39b
2 changed files with 7 additions and 3 deletions

View file

@ -473,7 +473,7 @@ namespace MinecraftClient.Protocol.Message
{
List<string> using_data = new();
if (obj.ContainsKey("using") && !obj.ContainsKey("with"))
obj["with"] = System.Text.Json.Nodes.JsonNode.Parse(obj["using"]!.ToJsonString());
obj["with"] = obj["using"]!.DeepClone();
if (obj.ContainsKey("with"))
{
foreach (var item in obj["with"]!.AsArray())

View file

@ -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)