Internet Explorer 8 + Deflate

Ich habe ein sehr seltsames Problem. Ich hoffe wirklich, dass jemand eine Antwort hat, weil ich nicht wüsste, wo ich sonst fragen soll.

Ich schreibe eine CGI-Anwendung in C ++, die von Apache ausgeführt wird und HTML-Code ausgibt. Ich komprimiere die HTML-Ausgabe selbst - aus meiner C ++ - Anwendung heraus - da mein Webhost mod_deflate aus irgendeinem Grund nicht unterstützt.

Ich habe dies mit Firefox 2, Firefox 3, Opera 9, Opera 10, Google Chrome, Safari, IE6, IE7, IE8 getestet. Es funktioniert mitETWAS außer IE8.

IE8 sagt nur "Internet Explorer kann die Webseite nicht anzeigen", ohne jegliche Information. Ich weiß, es liegt an der Komprimierung, nur weil es funktioniert, wenn ich es deaktiviere.

Weißt du was ich falsch mache?

Ich benutze Zlib, um es zu komprimieren, und der genaue Code ist:

    /* 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;
cgiHeaderContentType("text/html");
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;
return;
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage