陸壓請進。。。解碼問題

文章內容

(你知道的)-- 拿回來的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
『人生游戲,游戲人生』


日志分類
最新日志
此功能已被空間主人關閉
博客搜索
 
快速導航
友情鏈接
此功能已被空間主人關閉
博客統計
點擊: 690686
帖子數量: 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

加西網為北美中文網傳媒集團旗下網站