diff --git a/src/Milky/CheckerBuilder.cs b/src/Milky/CheckerBuilder.cs index 0b31e58..e711684 100644 --- a/src/Milky/CheckerBuilder.cs +++ b/src/Milky/CheckerBuilder.cs @@ -72,7 +72,7 @@ public CheckerBuilder WithProxiesFromUrl(string url, ProxySettings settings) { var responseString = _lazyWebClient.Value.DownloadString(url); - string[] proxies = responseString.Split(new[] { @"\n", @"\r" }, StringSplitOptions.RemoveEmptyEntries); + string[] proxies = responseString.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); WithProxies(proxies, settings); diff --git a/src/Milky/Models/Proxy.cs b/src/Milky/Models/Proxy.cs index a13ed2f..01ca661 100644 --- a/src/Milky/Models/Proxy.cs +++ b/src/Milky/Models/Proxy.cs @@ -46,9 +46,9 @@ public Proxy(string proxy, ProxySettings settings) internal NetworkCredential Credentials { get; } - internal HttpClient GetHttpClient() + public HttpClient GetHttpClient(CookieContainer cookieContainer = null) { - var httpMessageHandler = GetHttpMessageHandler(); + var httpMessageHandler = GetHttpMessageHandler(cookieContainer); var httpClient = new HttpClient(httpMessageHandler) { @@ -63,7 +63,7 @@ internal HttpClient GetHttpClient() return httpClient; } - private HttpMessageHandler GetHttpMessageHandler() + public HttpMessageHandler GetHttpMessageHandler(CookieContainer cookieContainer = null) { if (Settings.Protocol == ProxyProtocol.HTTP) { @@ -72,7 +72,7 @@ private HttpMessageHandler GetHttpMessageHandler() Proxy = new WebProxy(Host, Port) { Credentials = Credentials }, AllowAutoRedirect = Settings.AllowAutoRedirect, UseCookies = Settings.UseCookies, - CookieContainer = Settings.CookieContainer ?? new CookieContainer() + CookieContainer = cookieContainer ?? new CookieContainer() }; } @@ -92,19 +92,19 @@ private HttpMessageHandler GetHttpMessageHandler() { AllowAutoRedirect = Settings.AllowAutoRedirect, UseCookies = Settings.UseCookies, - CookieContainer = Settings.CookieContainer + CookieContainer = cookieContainer }, ProxyProtocol.SOCKS4A => new ProxyClientHandler(proxySettings) { AllowAutoRedirect = Settings.AllowAutoRedirect, UseCookies = Settings.UseCookies, - CookieContainer = Settings.CookieContainer + CookieContainer = cookieContainer }, ProxyProtocol.SOCKS5 => new ProxyClientHandler(proxySettings) { AllowAutoRedirect = Settings.AllowAutoRedirect, UseCookies = Settings.UseCookies, - CookieContainer = Settings.CookieContainer + CookieContainer = cookieContainer } }; } diff --git a/src/Milky/Models/ProxySettings.cs b/src/Milky/Models/ProxySettings.cs index 6c66eb6..1cbfa66 100644 --- a/src/Milky/Models/ProxySettings.cs +++ b/src/Milky/Models/ProxySettings.cs @@ -29,10 +29,5 @@ public ProxySettings(ProxyProtocol protocol) /// Whether or not to use/save/keep cookies, usually not recommended for credential stuffing but who knows /// public bool UseCookies { get; set; } = false; - - /// - /// Default , I see no use case for it for credential stuffing but who knows - /// - public CookieContainer CookieContainer { get; set; } = null; } }