/// <summary> /// 超时测试 /// </summary> /// <returns></returns> public override byte[] GetData() { //得到responsebody HttpWebResponse res = HttpUtilV2.createGetResponse(Url, 10); byte[] bResponseBody = HttpUtilV2.getResponseBody(res); return(bResponseBody); }
/// <summary> /// 获取数据 /// </summary> /// <returns></returns> public override byte[] GetData() { HttpWebRequest req = HttpUtilV2.createPostRequest(Url); req.Timeout = 10000; req.ContentLength = 0; req.ContentType = "text/plain;charset=UTF-8"; req.Headers["X-Requested-With"] = "XMLHttpRequest"; HttpWebResponse res = (HttpWebResponse)req.GetResponse(); byte[] bResponseBody = HttpUtilV2.getResponseBody(res); return(bResponseBody); }
/// <summary> /// 获取内容 /// .可以重写 /// </summary> /// <returns></returns> public override byte[] GetData() { //得到responsebody byte[] responsebody = null; if (HttpType == AqiConstant.HttpType.POST) { responsebody = HttpUtilV2.doPostRequest(Url, null); } else { responsebody = HttpUtilV2.doGetRequest(Url); } return(ExtractData(responsebody)); }
/// <summary> /// 获取响应体 /// .可以重写 /// </summary> /// <returns></returns> public virtual byte[] GetData() { //得到responsebody byte[] responsebody = null; if (HT == AqiConstant.HttpType.POST) { responsebody = HttpUtilV2.doPostRequest(Url, null); } else { responsebody = HttpUtilV2.doGetRequest(Url); } return(responsebody); }
/// <summary> /// 获取内容 /// 可以重写 /// </summary> /// <param name="param">参数列表</param> /// <returns></returns> public virtual byte[] GetData(AqiParam param) { HttpWebResponse response = null; try { Dictionary <string, string> header = MakeRequestHeader(param); switch (ParamSendType) { case AqiConstant.ParamSendType.GET: string urlparam = MakeUrl(param); response = HttpUtilV2.createGetResponse(urlparam, -1, header); break; case AqiConstant.ParamSendType.POST: byte[] requestbody = MakeRequestBody(param); response = HttpUtilV2.createPostResponse(Url, -1, header, requestbody); break; default: throw new NotSupportedException("ParamSendType only for GET/POST"); } } catch (System.Exception ex) { throw new DataUnHoldException("无法获取数据", ex); } HttpData data = HttpUtilV2.GetHttpData(response); //缓存数据 if (this is ICacheData) { ((ICacheData)this).Data = data; } //提取数据 if (this is IExtractData) { return(((IExtractData)this).ExtractData(data.Body)); } return(data.Body); }
/// <summary> /// 获取内容 /// 可以重写 /// </summary> /// <param name="param">参数列表</param> /// <returns></returns> public virtual byte[] GetData(AqiParam param) { //得到responsebody byte[] responsebody = null; switch (ParamSendType) { case AqiConstant.ParamSendType.GET: string urlparam = MakeUrl(param); responsebody = HttpUtilV2.doGetRequest(urlparam); break; case AqiConstant.ParamSendType.POST: byte[] requestbody = MakeRequestBody(param); responsebody = HttpUtilV2.doPostRequest(Url, requestbody); break; default: responsebody = HttpUtilV2.doGetRequest(Url); break; } return(ExtractData(responsebody)); }