Skip to content

Commit

Permalink
Fix: Get wrong http headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyfish committed Jun 20, 2024
1 parent de5fefc commit 38639cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions AutoUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public static async Task<bool> 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;

Expand Down
10 changes: 5 additions & 5 deletions HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -36,7 +36,7 @@ public class HttpHeaders(HttpResponseHeaders responseHeaders)

public static async Task<HttpHeaders?> GetHeaders(string url)
{
var respondHeaders = await GetHttpRespondHeaders(url);
var respondHeaders = await GetHttpContentHeaders(url);
if (respondHeaders == null)
return null;

Expand All @@ -53,7 +53,7 @@ private static HttpClient GetHttpClient()
return client;
}

private static async Task<HttpResponseHeaders?> GetHttpRespondHeaders(string url)
private static async Task<HttpContentHeaders?> GetHttpContentHeaders(string url)
{
try
{
Expand All @@ -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)
{
Expand Down

0 comments on commit 38639cd

Please sign in to comment.