diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClient.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs index c016e5332..70f97225a 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs @@ -54,12 +54,9 @@ namespace Jackett.Common.Utils.Clients public static void InitProxy(ServerConfig serverConfig) { // dispose old SocksWebProxy - if (webProxy != null && webProxy is SocksWebProxy) - { - ((SocksWebProxy)webProxy).Dispose(); - webProxy = null; - } - + if (webProxy is SocksWebProxy proxy) + proxy.Dispose(); + webProxy = null; webProxyUrl = serverConfig.GetProxyUrl(); if (!string.IsNullOrWhiteSpace(webProxyUrl)) { diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs index 19bfd7b43..053b374d1 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs @@ -61,12 +61,9 @@ namespace Jackett.Common.Utils.Clients public static void InitProxy(ServerConfig serverConfig) { // dispose old SocksWebProxy - if (webProxy != null && webProxy is SocksWebProxy) - { - ((SocksWebProxy)webProxy).Dispose(); - webProxy = null; - } - + if (webProxy is SocksWebProxy proxy) + proxy.Dispose(); + webProxy = null; webProxyUrl = serverConfig.GetProxyUrl(); if (!string.IsNullOrWhiteSpace(webProxyUrl)) { diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClient2NetCore.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient2NetCore.cs index 11849b4d6..9796082ec 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClient2NetCore.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient2NetCore.cs @@ -57,12 +57,9 @@ namespace Jackett.Common.Utils.Clients public static void InitProxy(ServerConfig serverConfig) { // dispose old SocksWebProxy - if (webProxy != null && webProxy is SocksWebProxy) - { - ((SocksWebProxy)webProxy).Dispose(); - webProxy = null; - } - + if (webProxy is SocksWebProxy proxy) + proxy.Dispose(); + webProxy = null; webProxyUrl = serverConfig.GetProxyUrl(); if (!string.IsNullOrWhiteSpace(webProxyUrl)) { diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClientNetCore.cs b/src/Jackett.Common/Utils/Clients/HttpWebClientNetCore.cs index c54aaef29..e4828d4ce 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClientNetCore.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClientNetCore.cs @@ -53,12 +53,9 @@ namespace Jackett.Common.Utils.Clients public static void InitProxy(ServerConfig serverConfig) { // dispose old SocksWebProxy - if (webProxy != null && webProxy is SocksWebProxy) - { - ((SocksWebProxy)webProxy).Dispose(); - webProxy = null; - } - + if (webProxy is SocksWebProxy proxy) + proxy.Dispose(); + webProxy = null; webProxyUrl = serverConfig.GetProxyUrl(); if (!string.IsNullOrWhiteSpace(webProxyUrl)) {