Ejemplo n.º 1
0
        public static string HttpGetStrContentByGet(string url)
        {
            int         bufferSize = 1024;
            HTTPPackage package    = new HTTPPackage(bufferSize);
            string      content    = "";

            NetModel.NetMgr.Http.HttpHelper.CreateGetHttpResponse(
                url,
                10000,
                null,
                null,
                (data, count) =>
            {
                if (count.Equals(0))
                {
                    byte[] str = package.GetData();
                    package.Clear();
                    package = null;
                    content = Encoding.UTF8.GetString(str);
                }
                else if (count.Equals(-1))
                {
                    throw new NullReferenceException(Encoding.UTF8.GetString(data));
                }
                else
                {
                    package.AddBuffer(data, count);
                }
            },
                err =>
            {
                throw new NullReferenceException(string.Format("地址:{0}的网络访问出错=====>>{1}", url, err));
            });
            return(content);
        }
Ejemplo n.º 2
0
        public static string HttpPostFormMsg(string url, FormData form, int timeout = 10000)
        {
            int         bufferSize = 1024;
            HTTPPackage package    = new HTTPPackage(bufferSize);
            string      content    = "";

            NetModel.NetMgr.Http.HttpHelper.HttpPostData(
                url,
                timeout,
                form,
                null,
                null,
                (tmpData, count) =>
            {
                if (count.Equals(0))
                {
                    byte[] str = package.GetData();
                    package.Clear();
                    package = null;
                    content = Encoding.UTF8.GetString(str);
                }
                else if (count.Equals(-1))
                {
                    throw new NullReferenceException(Encoding.UTF8.GetString(tmpData));
                }
                else
                {
                    package.AddBuffer(tmpData, count);
                }
            },
                err =>
            {
                throw new NullReferenceException(string.Format("地址:{0}的网络访问出错=====>>{1}", url, err));
            });
            return(content);
        }