From 38639cde1a72a1d6240142bfac204e877f485c52 Mon Sep 17 00:00:00 2001 From: Tinyfish Date: Thu, 20 Jun 2024 16:16:34 +0800 Subject: [PATCH] Fix: Get wrong http headers. --- AutoUpdate.cs | 3 +-- HttpHelper.cs | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/AutoUpdate.cs b/AutoUpdate.cs index 080242a..eb161c9 100644 --- a/AutoUpdate.cs +++ b/AutoUpdate.cs @@ -12,8 +12,7 @@ public static async Task HasUpdate() return false; // Get the CloudFlare cache time - var updateTime = headers.LastModified - ?? headers.GetDateTime("x-ms-creation-time"); + var updateTime = headers.LastModified; if (updateTime == null) return false; diff --git a/HttpHelper.cs b/HttpHelper.cs index e24a7e0..84dd99f 100644 --- a/HttpHelper.cs +++ b/HttpHelper.cs @@ -3,7 +3,7 @@ public class HttpHelper { - public class HttpHeaders(HttpResponseHeaders responseHeaders) + public class HttpHeaders(HttpContentHeaders responseHeaders) { public DateTime? LastModified => GetDateTime("Last-Modified"); public int FileSize => GetInt("Content-Length") ?? -1; @@ -36,7 +36,7 @@ public class HttpHeaders(HttpResponseHeaders responseHeaders) public static async Task GetHeaders(string url) { - var respondHeaders = await GetHttpRespondHeaders(url); + var respondHeaders = await GetHttpContentHeaders(url); if (respondHeaders == null) return null; @@ -53,7 +53,7 @@ private static HttpClient GetHttpClient() return client; } - private static async Task GetHttpRespondHeaders(string url) + private static async Task GetHttpContentHeaders(string url) { try { @@ -70,10 +70,10 @@ private static HttpClient GetHttpClient() if (string.IsNullOrEmpty(redirectUrl)) return null; - return await GetHttpRespondHeaders(redirectUrl); + return await GetHttpContentHeaders(redirectUrl); } - return response.Headers; + return response.Content.Headers; } catch (Exception ex) {