using CsharpHttpHelper.Base; using CsharpHttpHelper.Enum; using CsharpHttpHelper.Helper; using System.Drawing; namespace CsharpHttpHelper.BaseBll { /// /// 具体实现方法 Copyright:http://www.httphelper.com/ /// internal class HttpHelperBll { /// /// Httphelper原始访问类对象 /// private HttphelperBase httpbase = new HttphelperBase(); /// /// 根据相传入的数据,得到相应页面数据 /// /// 参数类对象 /// 返回HttpResult类型 internal HttpResult GetHtml(HttpItem item) { if (item.Allowautoredirect && item.AutoRedirectCookie) { HttpResult httpResult = null; for (int i = 0; i < 100; i++) { item.Allowautoredirect = false; httpResult = httpbase.GetHtml(item); if (string.IsNullOrWhiteSpace(httpResult.RedirectUrl)) { break; } item.URL = httpResult.RedirectUrl; item.Method = "GET"; if (item.ResultCookieType == ResultCookieType.String) { item.Cookie += httpResult.Cookie; } else { item.CookieCollection.Add(httpResult.CookieCollection); } } return httpResult; } return httpbase.GetHtml(item); } /// /// 根据Url获取图片 /// /// 参数类对象 /// 返回图片 internal Image GetImage(HttpItem item) { item.ResultType = ResultType.Byte; return ImageHelper.ByteToImage(GetHtml(item).ResultByte); } /// /// 快速Post数据这个访求与GetHtml一样,只是不接收返回数据,只做提交。 /// /// 参数类对象 /// 返回HttpResult类型 internal HttpResult FastRequest(HttpItem item) { return httpbase.FastRequest(item); } } }