fix: rest client add webporxy config, keep the processing logic with WebSocketProvider (#2974)
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user