From 9dc4ef7bceefce2119f4d879b61dc189f1420ced Mon Sep 17 00:00:00 2001 From: xRain Date: Thu, 18 Dec 2025 16:17:18 +0800 Subject: [PATCH] =?UTF-8?q?http=20client=20=E5=A2=9E=E5=8A=A0=E4=BA=86Debu?= =?UTF-8?q?gLog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Helpers/SimApiHttpClient.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Helpers/SimApiHttpClient.cs b/Helpers/SimApiHttpClient.cs index 9092520..cb6443a 100644 --- a/Helpers/SimApiHttpClient.cs +++ b/Helpers/SimApiHttpClient.cs @@ -8,7 +8,7 @@ using SimApi.Exceptions; namespace SimApi.Helpers; -public class SimApiHttpClient(string? appId, string appKey) +public class SimApiHttpClient(string? appId, string appKey, bool debug = false) { public string Server { get; init; } = string.Empty; public string SignName { get; init; } = "sign"; @@ -17,7 +17,6 @@ public class SimApiHttpClient(string? appId, string appKey) public string? AppIdName { get; init; } = "appId"; public string[] SignFields { get; init; } = []; - public T? SignQuery(string url, object? body = null, Dictionary? queries = null) { url = Server + url; @@ -68,7 +67,17 @@ public class SimApiHttpClient(string? appId, string appKey) private T? Query(string url, object? req) { var http = new HttpClient(); + if (debug) + { + Console.WriteLine($"[HTTPCLIENT请求] {url}\n{SimApiUtil.Json(req)}\n"); + } + var resp = http.PostAsJsonAsync(url, req).Result; + if (debug) + { + Console.WriteLine($"[HTTPCLIENT响应] {resp.Content.ReadAsStringAsync().Result}\n"); + } + var res = resp.Content.ReadFromJsonAsync>().Result; if (res == null) {