网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Howtogethttpresponse.-创新互联

成都创新互联公司服务项目包括高明网站建设、高明网站制作、高明网页制作以及高明网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,高明网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到高明省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!>public class HttpWebResponseUtility { public static string CreateGetHttpResponse(string url) { var response = CreateGetHttpResponse(url, null); Stream dataStream= response.GetResponseStream(); StreamReader reader= new StreamReader(dataStream); string responseString = reader.ReadToEnd(); return responseString; } public static string CreatePostHttpResponse(string url, IDictionary parameters) { var response = CreatePostHttpResponse(url, parameters,null,System.Text.Encoding.UTF8); Stream dataStream= response.GetResponseStream(); StreamReader reader= new StreamReader(dataStream); string responseString = reader.ReadToEnd(); return responseString; } public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException("url"); } var request = WebRequest.Create(url) as HttpWebRequest; request.Method= "GET"; request.Proxy= null; request.Credentials= CredentialCache.DefaultCredentials; //allows for validation of SSL certificates ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); if (timeout.HasValue) { request.Timeout= timeout.Value; } return request.GetResponse() as HttpWebResponse; } public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary parameters, int? timeout, Encoding requestEncoding) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException("url"); } if (requestEncoding == null) { throw new ArgumentNullException("requestEncoding"); } HttpWebRequest request= null; if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { ServicePointManager.ServerCertificateValidationCallback= new RemoteCertificateValidationCallback(CheckValidationResult); request= WebRequest.Create(url) as HttpWebRequest; request.Proxy= null; request.Credentials= CredentialCache.DefaultCredentials; request.ProtocolVersion= HttpVersion.Version10; } else { request= WebRequest.Create(url) as HttpWebRequest; } request.Method= "POST"; request.ContentType= "application/x-www-form-urlencoded"; if (timeout.HasValue) { request.Timeout= timeout.Value; } if (!(parameters == null || parameters.Count == 0)) { StringBuilder buffer= new StringBuilder(); int i = 0; foreach (string key in parameters.Keys) { if (i > 0) { buffer.AppendFormat("&{0}={1}", key, parameters[key]); } else { buffer.AppendFormat("{0}={1}", key, parameters[key]); } i++; } byte[] data = requestEncoding.GetBytes(buffer.ToString()); using (Stream stream = request.GetRequestStream()) { stream.Write(data,0, data.Length); } } return request.GetResponse() as HttpWebResponse; } private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; //总是接受 } }
分享标题:Howtogethttpresponse.-创新互联
文章来源:http://bjjierui.cn/article/ceshjh.html

其他资讯