日期:2014-05-17 浏览次数:20588 次
/// <summary>
/// 解析Cookie
/// </summary>
/// <param name="response"></param>
private void ParseCookie(HttpWebResponse response)
{
if (!IgnoreCookies)
{
string cookiesExpression = response.Headers["Set-Cookie"];
if (!string.IsNullOrEmpty(cookiesExpression))
{
Uri cookieUrl = new Uri(string.Format("{0}://{1}:{2}/",
response.ResponseUri.Scheme,
response.ResponseUri.Host,
response.ResponseUri.Port));
_cookieContainer.SetCookies(cookieUrl, cookiesExpression);
}
}
}
/// <summary>
/// 配置请求设置
/// </summary>
/// <param name="request"></param>
private void ConfigRequest(HttpWebRequest request)
{
request.UserAgent = UserAgent;
request.Referer= "";
request.CookieContainer = _cookieContainer;
request.AllowAutoRedirect =AllowAutoRedirect;
request.MediaType = "text/html";
request.Headers["Accept-Language"] = "zh-CN,zh;q=0.8";
if (Timeout >&nb