使用GetResponseStream readToEnd读取HTTPWebReponse返回奇怪的字符

编程入门 行业动态 更新时间:2024-10-25 22:35:00
本文介绍了使用GetResponseStream readToEnd读取HTTPWebReponse返回奇怪的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们正在读取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返回奇怪的字符

本文发布于:2023-11-10 03:06:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   奇怪   GetResponseStream   readToEnd   HTTPWebReponse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!