Archived
Added: ignore ssl option
This commit is contained in:
1 parent
60f199b0f2
commit
00f58d8259
7 files changed
+80
-36
No files matched your search
+25
-18
@@ -8,35 +8,41 @@ namespace RyzStudio.Net
|
||||
{
|
||||
public class HttpWeb
|
||||
{
|
||||
public string defaultUserAgent = "Momozilla/5.0 (" + Environment.OSVersion.Platform.ToString() + " ; " + Environment.OSVersion.VersionString + "; " + Application.CurrentCulture.TwoLetterISOLanguageName + ")";
|
||||
public int defaultTimeout = 6000;
|
||||
public int defaultMaxRedirect = 8;
|
||||
public bool defaultAllowRedirect = true;
|
||||
public CookieContainer defaultCookierContainer = null;
|
||||
|
||||
|
||||
public HttpWeb()
|
||||
{
|
||||
}
|
||||
|
||||
public HttpWebRequest CreateRequest(string url)
|
||||
{
|
||||
return this.CreateRequest(url, url);
|
||||
}
|
||||
|
||||
public string UserAgent { get; set; } = "Momozilla/5.0 (" + Environment.OSVersion.Platform.ToString() + " ; " + Environment.OSVersion.VersionString + "; " + Application.CurrentCulture.TwoLetterISOLanguageName + ")";
|
||||
|
||||
public int Timeout { get; set; } = 6000;
|
||||
|
||||
public int MaxRedirect { get; set; } = 8;
|
||||
|
||||
public bool AllowRedirect { get; set; } = true;
|
||||
|
||||
public bool IgnoreSSL { get; set; } = false;
|
||||
|
||||
public CookieContainer CookierJar { get; set; } = null;
|
||||
|
||||
|
||||
public HttpWebRequest CreateRequest(string url) => this.CreateRequest(url, url);
|
||||
|
||||
public HttpWebRequest CreateRequest(string url, string referrerURL)
|
||||
{
|
||||
if (defaultCookierContainer == null)
|
||||
{
|
||||
defaultCookierContainer = new CookieContainer();
|
||||
}
|
||||
if (this.CookierJar == null) this.CookierJar = new CookieContainer();
|
||||
|
||||
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
|
||||
webRequest.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
||||
webRequest.MaximumAutomaticRedirections = defaultMaxRedirect;
|
||||
webRequest.CookieContainer = defaultCookierContainer;
|
||||
webRequest.UserAgent = defaultUserAgent;
|
||||
webRequest.AllowAutoRedirect = defaultAllowRedirect;
|
||||
webRequest.Timeout = defaultTimeout;
|
||||
webRequest.MaximumAutomaticRedirections = this.MaxRedirect;
|
||||
webRequest.CookieContainer = this.CookierJar;
|
||||
webRequest.UserAgent = this.UserAgent;
|
||||
webRequest.AllowAutoRedirect = this.AllowRedirect;
|
||||
webRequest.Timeout = this.Timeout;
|
||||
|
||||
if (this.IgnoreSSL) webRequest.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
|
||||
return webRequest;
|
||||
}
|
||||
@@ -164,5 +170,6 @@ namespace RyzStudio.Net
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user