开发者

When using response compression in c#, will later use of IIS compression cause problems?

开发者 https://www.devze.com 2023-02-24 19:54 出处:网络
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 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")) 
            { 
                con开发者_如何学运维text.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?

0

精彩评论

暂无评论...
验证码 换一张
取 消