public static void PutFile(string url, HttpPara para, string file) { HttpWebRequest request = HttpWebUtility.Create(url, para, "PUT", null); HttpWebUtility.SentFile(request, file); HttpWebUtility.Receive(request); }
public static void PutImage(string url, HttpPara para, Image image) { HttpWebRequest request = HttpWebUtility.Create(url, para, "PUT", null); HttpWebUtility.SentImage(request, image); HttpWebUtility.Receive(request); }
public static void PutText(string url, HttpPara para, string text) { HttpWebRequest request = HttpWebUtility.Create(url, para, "PUT", null); HttpWebUtility.SentText(request, text); HttpWebUtility.Receive(request); }
public static string Post(string url, HttpPara para, string text = null) { HttpWebRequest request = HttpWebUtility.Create(url, para, "POST", "application/x-www-form-urlencoded"); if (text != null) { HttpWebUtility.SentText(request, text); } return(HttpWebUtility.ReceiveString(request)); }
internal static HttpWebRequest Create(string url, HttpPara httpPara, string httpMethod, string contentType) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException(nameof(url)); } SetSecurityProtocol(url); HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.Method = httpMethod; request.UserAgent = DEFAULT_USER_AGENT; if (httpPara.Timeout != default) { request.Timeout = httpPara.Timeout; } if (httpPara.AuthHeader != null) { request.Headers.Add(httpPara.AuthHeader); } if (!string.IsNullOrEmpty(contentType)) { request.ContentType = contentType; } request.CookieContainer = new CookieContainer(); if (httpPara.Cookies != null) { request.CookieContainer.Add(httpPara.Cookies); } return(request); }
public static CookieCollection GetCookie(string url, HttpPara para) { HttpWebRequest request = HttpWebUtility.Create(url, para, "HEAD", null); return(HttpWebUtility.ReceiveCookie(request)); }
public static string Operate(string url, HttpPara para, string method) { HttpWebRequest request = HttpWebUtility.Create(url, para, method, null); return(HttpWebUtility.ReceiveString(request)); }
public static void GetFile(string url, HttpPara para, string savePath) { HttpWebRequest request = HttpWebUtility.Create(url, para, "GET", null); HttpWebUtility.ReceiveFile(request, savePath); }
public static string GetText(string url, HttpPara para) { HttpWebRequest request = HttpWebUtility.Create(url, para, "GET", null); return(HttpWebUtility.ReceiveString(request)); }