From f3e3153d0545db5cdf27c65346984371810e4f8c Mon Sep 17 00:00:00 2001 From: eunma Date: Wed, 18 Sep 2024 17:47:23 +0900 Subject: [PATCH] Bug fix --- Entities/ApiWebClient.cs | 2 +- Entities/ZipWebClient.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Entities/ApiWebClient.cs b/Entities/ApiWebClient.cs index 49fef931..8c050729 100644 --- a/Entities/ApiWebClient.cs +++ b/Entities/ApiWebClient.cs @@ -24,7 +24,7 @@ protected override WebRequest GetWebRequest(Uri address) { BypassProxyOnLocal = false }; - if (Stats.EnableProxyAuthentication) { + if (Stats.EnableProxyAuthentication && !string.IsNullOrEmpty(Stats.ProxyUsername) && !string.IsNullOrEmpty(Stats.ProxyPassword)) { webproxy.Credentials = new NetworkCredential(Stats.ProxyUsername, Stats.ProxyPassword); } diff --git a/Entities/ZipWebClient.cs b/Entities/ZipWebClient.cs index ff7cfaf6..b171fefb 100644 --- a/Entities/ZipWebClient.cs +++ b/Entities/ZipWebClient.cs @@ -17,6 +17,19 @@ protected override WebRequest GetWebRequest(Uri address) { HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address); request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; + + if (Stats.UseWebProxy && Stats.SucceededTestProxy) { + WebProxy webproxy = new WebProxy($"{Stats.ProxyAddress}:{(!string.IsNullOrEmpty(Stats.ProxyPort) ? Stats.ProxyPort : "80")}", false) { + BypassProxyOnLocal = false + }; + + if (Stats.EnableProxyAuthentication && !string.IsNullOrEmpty(Stats.ProxyUsername) && !string.IsNullOrEmpty(Stats.ProxyPassword)) { + webproxy.Credentials = new NetworkCredential(Stats.ProxyUsername, Stats.ProxyPassword); + } + + request.Proxy = webproxy; + } + return request; } }