From c51aaf0a95836b83bb4c209556cfddaf42ea3314 Mon Sep 17 00:00:00 2001 From: xxyy <cathay_xy@163.com> Date: 星期四, 06 三月 2025 10:09:49 +0800 Subject: [PATCH] 优化缓存使用和定时器设置 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs index 394f9de..54c3eba 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/HttpHelper.cs @@ -17,8 +17,11 @@ using HttpClient httpClient = new HttpClient(); httpClient.Timeout = new TimeSpan(0, 0, 60); - foreach (var header in headers) - httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + if (headers != null) + { + foreach (var header in headers) + httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + } result = await httpClient.GetAsync(serviceAddress).Result.Content.ReadAsStringAsync(); return result; @@ -41,8 +44,11 @@ using HttpClient httpClient = new HttpClient(); httpClient.Timeout = new TimeSpan(0, 0, 60); - foreach (var header in headers) - httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + if (headers != null) + { + foreach (var header in headers) + httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + } result = await httpClient.PostAsync(serviceAddress, httpContent).Result.Content.ReadAsStringAsync(); } -- Gitblit v1.9.3