Skip to content

Commit

Permalink
fix: rest client add webporxy config, keep the processing logic with …
Browse files Browse the repository at this point in the history
…WebSocketProvider (#2974)
  • Loading branch information
trueai-org authored Sep 14, 2024
1 parent 8a2ea4b commit 292f8c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Net/DefaultRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class DefaultRestClient : IRestClient, IDisposable
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;

Expand All @@ -34,6 +34,7 @@ public DefaultRestClient(string baseUrl, bool useProxy = false)
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
UseCookies = false,
UseProxy = useProxy,
Proxy = webProxy
});
#pragma warning restore IDISP014
SetHeader("accept-encoding", "gzip, deflate");
Expand Down
5 changes: 3 additions & 2 deletions src/Discord.Net.Rest/Net/DefaultRestClientProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Net;

namespace Discord.Net.Rest
{
Expand All @@ -7,13 +8,13 @@ public static class DefaultRestClientProvider
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)
{
Expand Down

0 comments on commit 292f8c4

Please sign in to comment.