使用RestSharp发布经过gzip压缩的JSON内容

3
标题就是要表达全部:我正在尝试使用RestSharp将gzipped JSON内容发布到IIS服务器。我已经搜索了很多,但所有的结果都是关于处理gzip响应的:RestSharp compress request while making rest call to server 或者只是声称RestSharp支持gzip的页面:http://www.bevanblackie.com/2012/03/restsharp-supports-gzip.html。通过简单地更改IIS配置,从IIS压缩响应非常容易。但我无法弄清楚如何向IIS Web服务器发布压缩内容。理想情况下,RestSharp会自动处理并查看服务器是否支持gzip压缩,如果不支持,则发送未压缩的POST。

1个回答

2
  1. 将Content-Type设置为"application/json"

    request.AddHeader("Content-Type", "application/json");

  2. 将Content-Encoding设置为"gzip"

    request.AddHeader("Content-Encoding", "gzip");


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接