@@ -22,7 +22,7 @@ namespace Discord.Net.Rest | |||||
private CancellationToken _cancelToken; | private CancellationToken _cancelToken; | ||||
private bool _isDisposed; | private bool _isDisposed; | ||||
public DefaultRestClient(string baseUrl) | |||||
public DefaultRestClient(string baseUrl, bool useProxy = false) | |||||
{ | { | ||||
_baseUrl = baseUrl; | _baseUrl = baseUrl; | ||||
@@ -30,7 +30,7 @@ namespace Discord.Net.Rest | |||||
{ | { | ||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, | AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, | ||||
UseCookies = false, | UseCookies = false, | ||||
UseProxy = false | |||||
UseProxy = useProxy, | |||||
}); | }); | ||||
SetHeader("accept-encoding", "gzip, deflate"); | SetHeader("accept-encoding", "gzip, deflate"); | ||||
@@ -4,16 +4,21 @@ namespace Discord.Net.Rest | |||||
{ | { | ||||
public static class DefaultRestClientProvider | public static class DefaultRestClientProvider | ||||
{ | { | ||||
public static readonly RestClientProvider Instance = url => | |||||
public static readonly RestClientProvider Instance = Create(); | |||||
public static RestClientProvider Create(bool useProxy = false) | |||||
{ | { | ||||
try | |||||
{ | |||||
return new DefaultRestClient(url); | |||||
} | |||||
catch (PlatformNotSupportedException ex) | |||||
return url => | |||||
{ | { | ||||
throw new PlatformNotSupportedException("The default RestClientProvider is not supported on this platform.", ex); | |||||
} | |||||
}; | |||||
try | |||||
{ | |||||
return new DefaultRestClient(url, useProxy); | |||||
} | |||||
catch (PlatformNotSupportedException ex) | |||||
{ | |||||
throw new PlatformNotSupportedException("The default RestClientProvider is not supported on this platform.", ex); | |||||
} | |||||
}; | |||||
} | |||||
} | } | ||||
} | } |