Finding chrome bugs

time to read 2 min | 336 words

That one was annoying to figure out. Take a look at the following code:

static void Main(string[] args)
{
    var listener = new HttpListener();
    listener.Prefixes.Add("http://+:8080/");
    listener.Start();

    Console.WriteLine("Started");

    while(true)
    {
        var context = listener.GetContext();
        context.Response.Headers["Content-Encoding"] = "deflate";
        context.Response.ContentType = "application/json";
        using(var gzip = new DeflateStream(context.Response.OutputStream, CompressionMode.Compress))
        using(var writer = new StreamWriter(gzip, Encoding.UTF8))
        {
            writer.Write("{\"CountOfIndexes\":1,\"ApproximateTaskCount\":0,\"CountOfDocuments\":0}");
            writer.Flush();
            gzip.Flush();
        }
        context.Response.Close();
    }
}

FireFox and IE have no trouble using this. But here is how it looks on Chrome.

image

To make matter worse, pay attention to the conditions of the bug:

  • If I use Gzip instead of deflate, it works.
  • If I use "text/plain” instead of “application/json”, it works.
  • If I tunnel this through Fiddler, it works.

I hate stupid bugs like that.