[CLOSED] Ext.Net Compression Utils bug with non Gzip support

  1. #1

    [CLOSED] Ext.Net Compression Utils bug with non Gzip support

    Hi,

    In Ext.Net.Utilities in the CompressionUtils class, you have this bit of code:

    public static void GZipAndSend(byte[] instance, string responseType)
    {
        if (CompressionUtils.IsGZipSupported)
        {
            CompressionUtils.Send(CompressionUtils.GZip(instance), responseType);
        }
        else
        {
            CompressionUtils.Send(instance, responseType);
        }
    }
    
    public static void Send(byte[] instance, string responseType)
    {
        HttpResponse response = HttpContext.Current.Response;
    
        response.AppendHeader("Content-Encoding", "gzip");
        response.Charset = "utf-8";
        response.ContentType = responseType;
        response.BinaryWrite(instance);
    }
    The problem is that the response header will always get Content-Encoding of "gzip" even if Gzip is not supported, because GZipAndSend calls Send() in both cases, and Send() always fixed the content-encoding to "gzip"

    This causes problems for example with IE6 and when using a DirectResponse to return to the browser. This means that when calling DirectRequest methods, it always results in a response failure for IE6.

    I found this when using an ashx, similar to this:

    using System.Web;
    using Ext.Net;
    
    namespace MyExample
    {
        public class Example : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/json";
    
                var response = new DirectResponse { Success = true };
    
                try
                {
                    // do stuff here
                }
                catch (Exception e)
                {
                    response.Success = false;
                    response.ErrorMessage = e.Message;
                }
    
                response.Return();
            }
    
            public bool IsReusable
            {
                get { return false; }
            }
        }
    }
    Is this something that can be looked at soon as I can't think of a workaround.

    Thanks!
    Last edited by Daniil; Jan 20, 2012 at 12:21 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Thanks for the report.

    We will investigate a possible fix.

    Please clarify does it cause the problem with IE6 only?
  3. #3
    Hi, fixed in SVN
    If you cannot update whole toolkit then grab changes from 3814 revision only
  4. #4
  5. #5
    Thanks for quick turnaround (again :))

    Yes, Daniil, this was mainly affecting IE6 (though I guess in theory it could affect other browsers where Gzip was not mentioned in the accept-headers of the request (e.g. a proxy server strips it out, etc)

    The problem was in the send method shown earlier, but it was also related to the test for whether GZip is supported: this is the old method that had an IE6 related dependency:

    public static bool IsGZipSupported
    {
        get
        {
            HttpRequest request = HttpContext.Current.Request;
    
            bool ie6 = request.Browser.IsBrowser("IE") && request.Browser.MajorVersion <= 6;
            string encoding = (request.Headers["Accept-Encoding"] ?? "").ToLowerInvariant();
    
            return !ie6 && encoding.Contains("gzip", "deflate");
        }
    }
    With Vladimir's fix, the Send method correctly only sends back a gzip header if GZip is really supported (so the IE6 check/workaround remains in the above property in place).

    You can mark this as fixed. (Is there a way for us to do this - can save you the hassle, though maybe less controllable :))
  6. #6
    Thanks for the clarification.

    Quote Originally Posted by anup View Post
    You can mark this as fixed. (Is there a way for us to do this - can save you the hassle, though maybe less controllable :))
    Don't worry, we do it ourselves :)

Similar Threads

  1. [FIXED] [1.2] GZip
    By uniway in forum Bugs
    Replies: 3
    Last Post: Nov 17, 2011, 5:55 PM
  2. [CLOSED] About Gzip Compression
    By nirajrdave in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 23, 2011, 2:12 PM
  3. htttp content compression error
    By Oread in forum 1.x Help
    Replies: 7
    Last Post: Jan 19, 2011, 10:09 AM
  4. coolite run in http compression host
    By sonnt in forum 1.x Help
    Replies: 1
    Last Post: Jun 25, 2010, 5:22 AM
  5. [CLOSED] [0.8.2] IE6 and Gzip
    By sidinwillis in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 19, 2010, 7:32 AM

Posting Permissions