diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Handle.cc | 4 | ||||
-rw-r--r-- | lib/LuaHandle.cc | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/Handle.cc b/lib/Handle.cc index e88663a..39bc981 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -927,7 +927,7 @@ int Handle::zlib_inflate(Handle * in, Handle * out) throw (GeneralException) { return total_out; } -int Handle::zlib_deflate(Handle * in, Handle * out, int level, bool raw) throw (GeneralException) { +int Handle::zlib_deflate(Handle * in, Handle * out, int level, bool raw, bool gzip) throw (GeneralException) { int ret, flush; z_stream s; unsigned char b_in[CHUNK]; @@ -944,7 +944,7 @@ int Handle::zlib_deflate(Handle * in, Handle * out, int level, bool raw) throw ( have = total_out = 0; - ret = deflateInit2(&s, level, Z_DEFLATED, raw ? -15 : 15, 8, Z_DEFAULT_STRATEGY); + ret = deflateInit2(&s, level, Z_DEFLATED, gzip ? 31 : (raw ? -15 : 15), 8, Z_DEFAULT_STRATEGY); if (ret != Z_OK) { throw GeneralException("zlib: deflateInit() failed: " + String(ret)); } diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index 5b0d85e..08f4911 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -831,8 +831,9 @@ int sLuaHandle::zlib_deflate(lua_State * __L) { int r; int level = Z_DEFAULT_COMPRESSION; bool raw = false; + bool gzip = false; - if ((n < 2) || (n > 4) || ((n >= 3) && !L->isnumber(3)) || ((n == 4) && !L->isboolean(4))) { + if ((n < 2) || (n > 5) || ((n >= 3) && !L->isnumber(3)) || ((n >= 4) && !L->isboolean(4)) || ((n >= 5) && !L->isboolean(5))) { L->error("Incorrect arguments to method `Handle::zlib_deflate'"); } @@ -840,10 +841,12 @@ int sLuaHandle::zlib_deflate(lua_State * __L) { d = L->recast<Handle>(2); if (n >= 3) level = L->tonumber(3); - if (n == 4) + if (n >= 4) raw = L->toboolean(4); + if (n >= 5) + gzip = L->toboolean(5); - r = Handle::zlib_deflate(s, d, level, raw); + r = Handle::zlib_deflate(s, d, level, raw, gzip); L->push((lua_Number) r); |