苏飞论坛

标题: 新增GZIP解压处理开关 IsGzip=true 之万能框架Htttphelper [打印本页]

作者: 站长苏飞    时间: 2016-8-30 11:40
标题: 新增GZIP解压处理开关 IsGzip=true 之万能框架Htttphelper
新增GZIP解压处理开关 IsGzip=true 之万能框架Htttphelper

导读部分


【HttpHelper万能框架】教程目录贴  http://www.sufeinet.com/thread-9989-1-1.html
【HttpHelper万能框架】源码购买帖  http://www.sufeinet.com/thread-9926-1-1.html

本功能可在线测试http://tool.sufeinet.com/HttpHel ...http://sufeinet.com
教程部分

方法很简单使用方式如下
[C#] 纯文本查看 复制代码
 //创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://appintf.youthlighting.cn:9878/dx-interface-app/v1/sys/version",//URL     必需项   
                Method = "get",//URL     可选项 默认为Get   
                ContentType = "text/html",//返回类型    可选项有默认值   
                //ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值  
                IsGzip=true
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;

            //状态码
            HttpStatusCode code = result.StatusCode;
            //状态描述
            string Des = result.StatusDescription;
            if (code == HttpStatusCode.OK)
            {
                //状态为200
            }


当然最关键的是这行IsGzip=true
[C#] 纯文本查看 复制代码
        private Boolean _isGzip = false;
        /// <summary>
        ///  是否执行Gzip解压 默认为否
        /// </summary>
        public Boolean IsGzip
        {
            get { return _isGzip; }
            set { _isGzip = value; }
        }

大家一定要记着,默认是不使用的哦,默认使用的是自动方式,但自动 识别毕竟是有弊端的,这个就是为了在自动识别不生效时可以手动配置


方便 大家自动控制。
好了就这样吧。有什么问题请回复本帖子。

作者: 站长苏飞    时间: 2016-8-30 11:44
另外告诉大家
原来999现在只需要499就可以拿到终身VIP 最后两天截至到明天24点,错过再无
请查看
http://www.sufeinet.com/thread-16985-1-1.html
作者: songwenqi    时间: 2016-8-30 11:48
强烈支持楼主ing……
作者: 水手    时间: 2016-8-30 12:04
支持~~~论坛越做越好了。
作者: 望峰息心    时间: 2024-6-25 13:06
返回的数据是 H4sIAAAAAAAEADMyMDLRNTDTNTJVMDS2MjCzMjYDAL/KC7ETAAAA
为什么设定GZIP 之后 就报错了

GZip 头中的幻数不正确。请确保正在传入 GZip 流。





欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4