陆压请进。。。解码问题

文章内容

(你知道的)-- 拿回来的response package标记是gzip,但是直接用.NET gzip lib函数解压缩,提示“不是正确的gzip格式,幻数错误”啥的,你是怎么解包的?

btw,现在用另外一个方案倒是挺方便的,但还是想自己解包 icon_rolleyes.gif
QR Code
请用微信 扫一扫 扫描上面的二维码,然后点击页面右上角的 ... 图标,然后点击 发送给朋友分享到朋友圈,谢谢!
分享:
分享到微信

文章评论

陆压
无题
tried DeflateStream ?

2014-09-28 08:30:19 | 引用
Re: 陆压请进。。。解码问题
I tried many different ways, and one of it like this:

代码:

                string tempstr = null;
                Encoding myencoding = Encoding.GetEncoding("gb2312");
                System.Net.WebResponse res = req.GetResponse();
                System.IO.Stream ReceiveStream = res.GetResponseStream();
                using (System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, myencoding))
                {
                    {
                        tempstr = sr.ReadToEnd();
                        sr.Close();
                    }

                    //Char[] read = new Char[256];
                    //int count = sr.Read(read, 0, 256);

                    //while (count > 0)
                    //{
                    //    String str = new String(read, 0, count);
                    //    tempstr += str;
                    //    count = sr.Read(read, 0, 256);
                    //}
                }

                byte[] rcvData = myencoding.GetBytes(tempstr);
                MemoryStream mStream = new MemoryStream(rcvData);
                mStream.Seek(0, SeekOrigin.Begin);
                DeflateStream unZipStream = new DeflateStream(mStream, CompressionMode.Decompress, true);
                object dsResult = null;
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                dsResult = (object)bFormatter.Deserialize(unZipStream);

                Out = dsResult.ToString();


It stops at 'Deserialize' for that error

2014-09-28 09:38:15 | 引用
webdriver
陆压
无题
At least, i would try deflate first, then decode the gb2312

2014-09-28 10:01:09 | 引用
无题
报告老大,这里有人明目张胆地教授机器人发帖技术。。。:lol:

2014-09-28 10:12:52 | 引用
本那比经略
六叔
无题
本那比经略 写道:
报告老大,这里有人明目张胆地教授机器人发帖技术。。。:lol:


原来你是装的

2014-09-28 11:23:15 | 引用
无题
陆压 写道:
At least, i would try deflate first, then decode the gb2312


if you have time, try on your side and let me know what you got.
for me a quick way to compare the result is to view what packets sniffer got.

2014-09-28 11:49:10 | 引用
webdriver
webdriver
Re: 陆压请进。。。解码问题
btw here is what the sniffer got the response header:

-------------------------------------------------------

HTTP/1.1 200 OK
Date: Sun, 28 Sep 2014 18:49:59 GMT
Server: Apache
.....
.....
.....
Content-Encoding: gzip
Vary: Accept-Encoding
X-Powered-By: PleskLin
MS-Author-Via: DAV
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=GB2312

------------------------------------------------------

2014-09-28 11:53:49 | 引用
无题
六叔 写道:
本那比经略 写道:
报告老大,这里有人明目张胆地教授机器人发帖技术。。。:lol:


原来你是装的


偶是组装的。。。:lol:

2014-09-28 12:08:39 | 引用
本那比经略
陆压
无题
代码:

            myReq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

that's all

2014-09-28 13:36:20 | 引用
无题
陆压 写道:
代码:

            myReq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

that's all

works for me.

2014-09-28 13:36:49 | 引用
陆压
上一页12下一页

发表评论

个人简介

webdriver
『人生游戏,游戏人生』


日志分类
最新日志
此功能已被空间主人关闭
博客搜索
 
快速导航
友情链接
此功能已被空间主人关闭
博客统计
点击: 654953
帖子数量: 691
开辟个人空间: 2008-10-15
最后更新: 2018-05-11
左邻右舍
 
 
 
 
 
The images, logos, trademarks used on this site and all forwarded content are the property of their respective owners.
We are not responsible for comments posted by our visitors, as they are the property of the poster.
All other content of this website is copyrighted by 加西网

Private Policy | moonlake oblog skin

加西网为北美中文网传媒集团旗下网站