日期:2014-05-17 浏览次数:21698 次
protected override WebRequest GetWebRequest(Uri address)
{
InitHeader();
Request = (HttpWebRequest)base.GetWebRequest(address);
Request.MaximumAutomaticRedirections = 1000;
if (Timeout <= 0)
Timeout = 60;
Request.Timeout = Timeout * 1000;
Request.ReadWriteTimeout = Timeout * 1000;
Request.AllowAutoRedirect = AllowAutoRedirect;
Request.CookieContainer = this._cookieContainer;
Request.KeepAlive = true;
Request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
if (address.ToString().StartsWith("https"))
{
Credentials = CredentialCache.DefaultNetworkCredentials;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback = callback;
}
return Request;
}
protected override WebResponse GetWebResponse(WebRequest request)
{
Response = (HttpWebResponse)base.GetWebResponse(request);
if (Response != null)
{
this._cookieContainer.Add(Response.Cookies);
}
return Response;
}
new WebClientEx().DownloadString("xxxxx")