zoukankan      html  css  js  c++  java
  • 获取http请求

        public  string GetUrlDate(string url, string method, string content)
        {
            string outstring = "";
            try
            {
                System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
                myRequest.Method = method;
                myRequest.KeepAlive = false;
                myRequest.ContentType = "application/x-www-form-urlencoded";

                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                string postData = content;
                byte[] data = encoding.GetBytes(postData);
                myRequest.ContentLength = data.Length;
                System.IO.Stream newStream = myRequest.GetRequestStream();
                newStream.Write(data, 0, data.Length);
                newStream.Close();


                using (System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse())
                {

                    System.IO.StreamReader sr = new System.IO.StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
                    outstring= sr.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                IExceptionPublisher Publisher = new ExceptionPublisher();
                Publisher.Publish(ex, null, null);
                outstring= "";
            }
            return outstring;
        }

  • 相关阅读:
    HBase 数据模型和架构
    Flume 自定义Sink
    Flume 自定义Source
    LuoguP5889 跳树 线段树
    线段树历史版本和
    LuoguP4183 [USACO18JAN]Cow at Large P 点分治+树状数组+prufer序列
    LuoguP3924 康娜的线段树 期望+线段树
    luoguP3710 方方方的数据结构 KDtree
    luoguP5154 数列游戏 区间DP
    LOJ#2206. 「HNOI2014」世界树 虚树+倍增
  • 原文地址:https://www.cnblogs.com/linzheng/p/1814162.html
Copyright © 2011-2022 走看看