Port #446 (Fix for #444 - HTTP compression error)

This commit is contained in:
Trustin Lee 2012-07-10 22:13:42 +09:00
parent 1c4d0d0f57
commit 6b5e3c5def

View File

@ -235,17 +235,13 @@ public class JdkZlibEncoder extends ZlibEncoder {
return future; return future;
} }
ByteBuf footer = Unpooled.EMPTY_BUFFER; ByteBuf footer = Unpooled.dynamicBuffer();
synchronized (deflater) { synchronized (deflater) {
int numBytes = 0;
deflater.finish(); deflater.finish();
if (!deflater.finished()) { while (!deflater.finished()) {
numBytes = deflater.deflate(encodeBuf, 0, encodeBuf.length); int numBytes = deflater.deflate(encodeBuf, 0, encodeBuf.length);
}
int footerSize = gzip ? numBytes + 8 : numBytes;
if (footerSize > 0) {
footer = Unpooled.buffer(footerSize);
footer.writeBytes(encodeBuf, 0, numBytes); footer.writeBytes(encodeBuf, 0, numBytes);
}
if (gzip) { if (gzip) {
int crcValue = (int) crc.getValue(); int crcValue = (int) crc.getValue();
int uncBytes = deflater.getTotalIn(); int uncBytes = deflater.getTotalIn();
@ -258,7 +254,6 @@ public class JdkZlibEncoder extends ZlibEncoder {
footer.writeByte(uncBytes >>> 16); footer.writeByte(uncBytes >>> 16);
footer.writeByte(uncBytes >>> 24); footer.writeByte(uncBytes >>> 24);
} }
}
deflater.end(); deflater.end();
} }