|
1金钱
本帖最后由 pppudir 于 2015-1-31 22:14 编辑
httphelper 老是卡在这里:
private void GetData(HttpItem item, HttpResult result)
{
#region base
//获取StatusCode
result.StatusCode = response.StatusCode;
未将对象引用设置到对象的实例
public static string GetHtml(string url, ref string cookie,Boolean autoredirect)
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
Cookie = cookie,
URL = url,
Method = "get",
Allowautoredirect = autoredirect,
};
HttpResult result = http.GetHtml(item);
cookie = result.Cookie;
return result.Html;
}
补充下:
步进跟进去
public HttpResult GetHtml(HttpItem item)
{
//返回参数
HttpResult result = new HttpResult();
try
{
//准备参数
SetRequest(item);
}
catch (Exception ex)
{
//配置参数时出错
return new HttpResult() { Cookie = string.Empty, Header = null, Html = ex.Message, StatusDescription = "配置参数时出错:" + ex.Message };
}
try
{
//请求数据
using (response = (HttpWebResponse)request.GetResponse())
{
GetData(item, result);
}
}
catch (WebException ex)
这里异常了“服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF”
|
|