使用GetResponseStream readToEnd读取HTTPWebReponse返回奇怪的字符 [英] Read HTTPWebReponse using GetResponseStream readToEnd return strange characters
问题描述
我们正在读取HttpWebResponse的响应,我们认为响应本身是非常正常的. 但是,当我们尝试读取字符串表示形式时,我们只会收到奇怪的字符,而不是json格式的普通字符. 谁能告诉我们这里有什么问题吗?欢迎任何问题或帮助,如果需要更多信息,请发表评论.谢谢
we are reading response from HttpWebResponse and the response itself is quite normal, we think. But when we try to read the string representation of that, we only receive strange characters instead of json formatted normal chars. Can anyone please tell us what is wrong here? Any question or help is welcomed, if more informations are needed, please comment. Thanks
推荐答案
响应内容编码标头为 gzip ,指示内容已由服务器压缩.
The response content encoding header is gzip indicating the content has been compressed by the server.
设置request.AutomaticDecompression
告诉HttpWebResponse
您希望它自动解压缩数据.
Set request.AutomaticDecompression
to tell the HttpWebResponse
you want it to decompress the data automatically.
这篇关于使用GetResponseStream readToEnd读取HTTPWebReponse返回奇怪的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!