Fix subscription requests missing Accept header (#10095)

This commit is contained in:
稔君
2026-09-04 10:47:36 +08:00
committed by GitHub
parent 4a59c7f4d6
commit 9451b69246
2 changed files with 7 additions and 1 deletions

View File

@@ -82,7 +82,7 @@ public static class SubscriptionHandler
private static DownloadService CreateDownloadHandler(string hashCode, Func<bool, string, Task> updateFunc)
{
var downloadHandle = new DownloadService();
var downloadHandle = new DownloadService { AcceptHeader = "*/*" };
downloadHandle.Error += (sender2, args) =>
{
updateFunc?.Invoke(false, $"{hashCode}{args.GetException().Message}");

View File

@@ -11,6 +11,8 @@ public class DownloadService
public event ErrorEventHandler? Error;
public string? AcceptHeader { get; init; }
private static readonly string _tag = "DownloadService";
/// <summary>
@@ -253,6 +255,10 @@ public class DownloadService
userAgent = Utils.GetVersion(false);
}
client.DefaultRequestHeaders.UserAgent.TryParseAdd(userAgent);
if (AcceptHeader.IsNotEmpty())
{
client.DefaultRequestHeaders.Accept.ParseAdd(AcceptHeader);
}
Uri uri = new(url);
//Authorization Header