Fiddler 对解码后的响应进行编码。我怎样才能在 vb.net 中做同样的事情?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13509005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fiddler encodes decoded response. How can I do the same in vb.net?
提问by deltu100
I am using httpwebrequest to get a response from a website. In this response I should see an xml. But in my response it just shows me jibberish. I used fiddler to see what I get. I get an encoded response, which I manually need to decode to see the contents(this is in fiddler).
我正在使用 httpwebrequest 从网站获取响应。在此响应中,我应该看到一个 xml。但在我的回应中,它只是让我胡言乱语。我用提琴手来看看我得到了什么。我得到一个编码的响应,我需要手动解码以查看内容(这是在 fiddler 中)。
How can I do the same thing in vb.net ?
我怎样才能在 vb.net 中做同样的事情?
editThe response comes back as https.
编辑响应返回为https。
I have tried:
我试过了:
HttpUtility.HtmlDecode(myResult,myStreamwriter)
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("www.url.com/$filetype=xml"), HttpWebRequest)
request.KeepAlive = True
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
request.ContentType = "text/xml, charset=utf-8"
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip,deflate,sdch")
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4")
request.Headers.Set(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
Using getResponse = request.GetResponse
Dim webServiceResponse = getResponse.GetResponseStream()
Dim xmlreader As New IO.StreamReader(webServiceResponse)
'here is where it shows a really gibberish output
Dim myResult As String = xmlreader.ReadToEnd()
回答by Kenneth Ito
Sounds like you need to decompress the response.
听起来您需要解压缩响应。
Have you tried HttpWebRequest AutomaticDecompression? http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.automaticdecompression.aspx
您是否尝试过 HttpWebRequest 自动解压?http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.automaticdecompression.aspx
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

