fix: rest client add webporxy config, keep the processing logic with WebSocketProvider (#2974)

This commit is contained in:
trueai-org
2024-09-15 00:25:40 +08:00
committed by GitHub
parent 8a2ea4bb58
commit 292f8c40eb
2 changed files with 5 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ namespace Discord.Net.Rest
private CancellationToken _cancelToken;
private bool _isDisposed;
public DefaultRestClient(string baseUrl, bool useProxy = false)
public DefaultRestClient(string baseUrl, bool useProxy = false, IWebProxy webProxy = null)
{
_baseUrl = baseUrl;
@@ -34,6 +34,7 @@ namespace Discord.Net.Rest
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
UseCookies = false,
UseProxy = useProxy,
Proxy = webProxy
});
#pragma warning restore IDISP014
SetHeader("accept-encoding", "gzip, deflate");

View File

@@ -1,4 +1,5 @@
using System;
using System.Net;
namespace Discord.Net.Rest
{
@@ -7,13 +8,13 @@ namespace Discord.Net.Rest
public static readonly RestClientProvider Instance = Create();
/// <exception cref="PlatformNotSupportedException">The default RestClientProvider is not supported on this platform.</exception>
public static RestClientProvider Create(bool useProxy = false)
public static RestClientProvider Create(bool useProxy = false, IWebProxy webProxy = null)
{
return url =>
{
try
{
return new DefaultRestClient(url, useProxy);
return new DefaultRestClient(url, useProxy, webProxy);
}
catch (PlatformNotSupportedException ex)
{