|
发表于 2017-5-31 21:38:35
|
显示全部楼层
很复杂的其中一步,也不太好发出来和让别人测试。我查看了httphelper类源代码,没发现什么问题,但是一直访问超时。我自己写了个特别简单的如下,借用了HttpItem:
string urltemp = item.URL;
string data = item.Postdata;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urltemp);
request.Method = item.Method;
request.UserAgent = item.UserAgent;
request.Referer = item.Referer;
request.Host = item.Host;
request.Accept = item.Accept;
request.KeepAlive = true;
request.ContentType = item.ContentType;
request.Timeout = item.Timeout;
request.ReadWriteTimeout = item.ReadWriteTimeout;
if (item.Header != null && item.Header.Count > 0)
{
foreach (string key in item.Header.AllKeys)
{
request.Headers.Add(key, item.Header[key]);
}
}
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(request.GetRequestStream()))
{
writer.Write(data);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.Accepted)
{
html = response.StatusDescription;
return html;
}
很奇怪,反而能通过,但是不稳定。就是有时能通过,有时卡住直到超时。而站长的httphelper类是一直超时。我对比了httphelper类源码,没发现问题,不知道站长能否看看,是哪里出了问题。嘻嘻 |
|