Пример #1
0
        public static T Post <T>(string url, HttpParam param = null, HttpParam getParam = null, int timeOut = TimeOut, Encoding encoding = null, CookieContainer cc = null, string refer = null)
        {
            var str = Post(url, param, getParam, timeOut, encoding, cc, refer);

            return(JsonConvert.DeserializeObject <T>(str));
            //return JsonHelper.Deserialize<T>(str);
        }
Пример #2
0
        /// <summary>
        /// 上传文件。formData参数附加到url
        /// </summary>
        public static string Upload(string url, HttpParam formData, string filePath)
        {
            var urlt = String.Format("{0}?{1}", url, formData == null ? "" : formData.Format());
            var data = new WebClient().UploadFile(urlt, "POST", filePath);

            return(Encoding.UTF8.GetString(data));
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="url"></param>
 /// <param name="param"></param>
 /// <param name="timeOut">单位:秒</param>
 /// <param name="encoding"></param>
 /// <param name="cc"></param>
 /// <param name="refer"></param>
 /// <returns></returns>
 public static Stream GetStream(string url, HttpParam param = null,
                                int timeOut = TimeOut, Encoding encoding = null, CookieContainer cc = null, string refer = null)
 {
     return(GetStream(url, FormatData(param), timeOut, encoding, cc, refer));
 }
Пример #4
0
        /// <summary>
        /// 以post方式提交,将响应编码为字串。
        /// </summary>
        /// <param name="url"></param>
        /// <param name="param"></param>
        /// <param name="getParam"></param>
        /// <param name="timeOut">单位:秒</param>
        /// <param name="encoding"></param>
        /// <param name="cc"></param>
        /// <param name="refer"></param>
        /// <returns></returns>
        public static string Post(string url, HttpParam param = null, HttpParam getParam = null, int timeOut = TimeOut, Encoding encoding = null, CookieContainer cc = null, string refer = null)
        {
            var urlt = string.Format("{0}{1}", url, getParam == null ? "" : string.Format("?{0}", getParam.Format()));

            return(Post(urlt, FormatData(param), null, timeOut, encoding, cc, refer));
        }