Note that there are some explanatory texts on larger screens.

plurals
  1. POGetResponseStream reading error with htmlagilitypack
    text
    copied!<p>Alright this is the whole function But the read values are extremely incorrect I don't know what can be the problem</p> <p>Edit Ok it seems like problem is about gzip compression. How can i decompress the GetResponseStream ?</p> <pre><code> public static List&lt;object&gt; func_DoHTTPWebRequest(PerVotingSite myPerVote, string srUrl, string srCookiePrev = "", string srRefererParameter = null, string srBrowserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31") { try { srUrl = "http://stackoverflow.com/"; // for testing purposes string srReferer = myPerVote.srReferer; if (srRefererParameter != null) srReferer = srRefererParameter; bool blKeepAlive = myPerVote.blKeepAlive; int irRequestTimeOut = myPerVote.irRequestsTimeOut; if (irRequestTimeOut == 0) irRequestTimeOut = OtomatikVoter.irTimeOut; bool blKeepCookies = myPerVote.blKeepCookies; HttpWebRequest hWebReq = (HttpWebRequest)WebRequest.Create(srUrl); hWebReq.KeepAlive = blKeepAlive; hWebReq.Referer = srReferer; hWebReq.Timeout = irRequestTimeOut; hWebReq.ReadWriteTimeout = irRequestTimeOut; hWebReq.UserAgent = srBrowserAgent; hWebReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; WebHeaderCollection myWebHeaderCollection = hWebReq.Headers; myWebHeaderCollection.Add("Accept-Language", "en-gb,en;q=0.5"); myWebHeaderCollection.Add("Accept-Encoding", "gzip, deflate"); if (srCookiePrev.Length &gt; 1) myWebHeaderCollection.Add("Cookie", srCookiePrev); string srCookie = ""; HtmlAgilityPack.HtmlDocument hDoc = new HtmlAgilityPack.HtmlDocument(); using (HttpWebResponse hWebResp = (HttpWebResponse)hWebReq.GetResponse()) { using (var resultStream = hWebResp.GetResponseStream()) { if (hWebResp.Headers["Set-Cookie"] != null &amp;&amp; blKeepCookies == true) srCookie = hWebResp.Headers["Set-Cookie"].ToString(); hDoc.Load(resultStream,Encoding.UTF8); } } return new List&lt;object&gt; { hDoc, srCookie, hWebReq }; } catch (Exception E) { SpecialFunctions.writeError(E, "func_DoHTTPWebRequest"); return null; } } </code></pre> <p>And here the read result</p> <p>This code was working before now i can't figure out why not working</p> <p>Visual Studio 2012 , C# 5</p> <p><a href="https://i.stack.imgur.com/QXw1h.png" rel="nofollow noreferrer">http://i.stack.imgur.com/QXw1h.png</a></p> <p><img src="https://i.stack.imgur.com/QXw1h.png" alt="enter image description here"></p> <p><a href="https://i.stack.imgur.com/QXw1h.png" rel="nofollow noreferrer">http://i.stack.imgur.com/QXw1h.png</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload