コード例 #1
0
 /// <summary>
 /// 设置 request对象
 /// </summary>
 /// <param name="items"></param>
 public void SetRequest(HttpRequestItem items)
 {
     _request = WebRequest.Create(new Uri(items.Url)) as HttpWebRequest;
     if (_request == null) return;
     _request.Method = items.Method;
     _request.Accept = items.Accept;
     _request.UserAgent = items.UserAgent;
     _request.KeepAlive = items.KeepAlive;
     _request.ContentType = items.ContentType;
     _request.Timeout = items.ReTimeOut;
     _request.Referer = items.Referer;
     _request.ContentLength = items.ContentLength;
     if (items.ReWebProxy != null)//设置代理
     {
         _request.Proxy = items.ReWebProxy;
     }
     if (!items.PostBytes.IsNullEmpty())
     {
         _request.GetRequestStream().Write(items.PostBytes, 0, items.ContentLength);
     }
 }
コード例 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="items"></param>
 public HttpWebHelper(HttpRequestItem items)
 {
     SetRequest(items);//填充对象
 }