I've got a very strange problem.. I truly do hope someone comes with an answer because I wouldn't know where else to request.

I'm writing a cgi application in C++ that is performed by Apache and results Html page. I'm blending the HTML output myself - from inside my C++ application - since my hosting company does not support mod_deflate for whatever reason.

I examined this with Opera 2, Opera 3, Opera 9, Opera 10, Google Chrome, Safari, IE6, IE7, IE8, even wget.. It really works with ANYTHING except IE8.

IE8 just states "Ie cannot display the web page", without any information whatsoever. I understand it's due to the compression only since it works basically disable it.

Are you aware what I am doing wrong?

I personally use zlib to compress it, and also the exact code is:

    /* Compress it */
int compressed_output_size = content.length() + (content.length() * 0.2) + 16;
char *compressed_output = (char *)Alloc(compressed_output_size);
int compressed_output_length;
Compress(compressed_output, compressed_output_size, (void *)content.c_str(), content.length(), &compressed_output_length);

/* Send the compressed header */
cout << "Content-Encoding: deflate\r\n";
cout << boost::format("Content-Length: %d\r\n") % compressed_output_length;
cout.write(compressed_output, compressed_output_length);

static void Compress(void *to, size_t to_size, void *from, size_t from_size, int *final_size)
int ret;
z_stream stream;

stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;

if ((ret = deflateInit(&stream, CompressionSpeed)) != Z_OK)
	COMPRESSION_ERROR("deflateInit() failed: %d", ret);

stream.next_out = (Bytef *)to;
stream.avail_out = (uInt)to_size;
stream.next_in = (Bytef *)from;
stream.avail_in = (uInt)from_size;

if ((ret = deflate(&stream, Z_NO_FLUSH)) != Z_OK)
	COMPRESSION_ERROR("deflate() failed: %d", ret);

if (stream.avail_in != 0)
	COMPRESSION_ERROR("stream.avail_in is not 0 (it's %d)", stream.avail_in);

if ((ret = deflate(&stream, Z_FINISH)) != Z_STREAM_END)
	COMPRESSION_ERROR("deflate() failed: %d", ret);

if ((ret = deflateEnd(&stream)) != Z_OK)
	COMPRESSION_ERROR("deflateEnd() failed: %d", ret);

if (final_size)
	*final_size = stream.total_out;

The gzip and deflate techniques aren't exactly the same... they're very close, but you will find some subtle variations using the header, so, should you improve your content-encoding, it's also wise to improve your parameters towards the encoding method (particularly, your window size)!

See: http://apcmag.com/improve_your_site_with_http_compression.htm

Most likely another browsers are disregarding your articles-encoding specs and doing a bit of automatic recognition, but IE8 isn't...

See: http://world wide web.zlib.internet/manual.html#deflateInit2


windowBits=-15  (negative so that the header is suppressed)

And employ "gzip" because the content-encoding

I needed to clarify what I have discovered about this, as I have written my very own deflate formula, my very own HTTP server, and also to my dismay IE8 also unsuccessful to identify my deflated content:

HTTP RFC is http://world wide web.frequently asked questions.org/ftp/rfc/rfc2616.pdf. Page 17 states both RFC 1950 and RFC 1951 can be used when carrying out a deflate within the HTTP headers. RFC 1950 is just determining the header and trailer bytes the deflate formula is determined in RFC 1951. After I designed this to spec, IE8 unsuccessful.

After I overlooked RFC 1950 and just did RFC 1951, it passed.

I'd assume, then, that IE8 is not following RFC 2616 page 17 properly, and the many other browsers are nice enough to simply accept either format.