在c#中使用响应压缩时,以后使用IIS压缩会导致问题吗?
我使用 Web 服务作为 XHR 请求的端点,并计划使用 gzip/deflate 压缩兼容浏览器的响应。
我正在使用基于 http://www.dominicpetifer.co.uk/Blog/17/gzip-compress-your-websites-html-css-script-in-code:
string acceptEncoding =
context.Request.Headers["Accept-Encoding"];
if (acceptEncoding.Contains("gzip"))
{
context.Response.Filter = new GZipStream(
context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader(
"Content-Encoding", "gzip");
}
else if (acceptEncoding.Contains("deflate"))
{
context.Response.Filter = new DeflateStream(
context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader(
"Content-Encoding", "deflate");
}
context.Response.Write(response);
以后的某个日期 IIS 压缩可能会被打开。这会破坏响应吗?
I am using a webservice as the endpoint for an XHR request, and planning on gzip/deflate compressing the response for compatible browsers.
I am using code based on http://www.dominicpettifer.co.uk/Blog/17/gzip-compress-your-websites-html-css-script-in-code :
string acceptEncoding =
context.Request.Headers["Accept-Encoding"];
if (acceptEncoding.Contains("gzip"))
{
context.Response.Filter = new GZipStream(
context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader(
"Content-Encoding", "gzip");
}
else if (acceptEncoding.Contains("deflate"))
{
context.Response.Filter = new DeflateStream(
context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader(
"Content-Encoding", "deflate");
}
context.Response.Write(response);
It is possible that at some later date IIS compression may be turned on. Would this break the response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论