Add custom HTTP headers for subscription updates (#10118)

* Add custom HTTP headers for subscription updates

* Res

---------

Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
稔君
2026-09-09 14:24:05 +08:00
committed by GitHub
parent 143ada1358
commit b10c16a94a
17 changed files with 485 additions and 35 deletions
+4 -2
View File
@@ -8,7 +8,8 @@ public class DownloaderHelper
private static readonly Lazy<DownloaderHelper> _instance = new(() => new());
public static DownloaderHelper Instance => _instance.Value;
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout,
IReadOnlyDictionary<string, string>? requestHeaders = null, string? acceptHeader = null)
{
if (url.IsNullOrEmpty())
{
@@ -28,6 +29,7 @@ public class DownloaderHelper
var requestConfiguration = new RequestConfiguration()
{
Headers = headers,
Accept = acceptHeader,
UserAgent = userAgent,
ConnectTimeout = connectTimeout * 1000,
Proxy = webProxy
@@ -37,7 +39,7 @@ public class DownloaderHelper
BlockTimeout = timeout * 1000,
MaxTryAgainOnFailure = 2,
RequestConfiguration = requestConfiguration,
CustomHttpMessageHandlerFactory = () => GetSocketsHttpHandler(requestConfiguration),
CustomHttpMessageHandlerFactory = () => HttpRequestHeadersHelper.CreateHandler(GetSocketsHttpHandler(requestConfiguration), requestHeaders),
};
await using var downloader = new Downloader.DownloadService(downloadOpt);