Correctly change the compression buffer we send.

For ie browser, we need to remove the two first bytes.
If we make our buffer start two bytes after, we also need to reduce the
size of the buffer by two bytes. Else we will read and send two extra
junk bytes.

Fix #15
This commit is contained in:
Matthieu Gautier 2017-03-15 09:43:26 +01:00
parent 0c01ec5bb5
commit a27010c247

View File

@ -167,7 +167,7 @@ bool compress_content(string &content,
comprLen = COMPRESSOR_BUFFER_SIZE;
compress(compr, &comprLen, (const Bytef*)(content.data()), contentLength);
if (comprLen > 2 && comprLen < contentLength) {
if (comprLen > 2 && comprLen < (contentLength+2)) {
/* /!\ Internet Explorer has a bug with deflate compression.
It can not handle the first two bytes (compression headers)
@ -175,6 +175,7 @@ bool compress_content(string &content,
It has no incidence on other browsers
See http://www.subbu.org/blog/2008/03/ie7-deflate-or-not and comments */
compr += 2;
comprLen -= 2;
content = string((char *)compr, comprLen);
contentLength = comprLen;