parent
5a93ad7867
commit
e56447dda3
|
@ -24,7 +24,7 @@ type
|
||||||
# should not be compressed.
|
# should not be compressed.
|
||||||
level: ZLevel # compression level
|
level: ZLevel # compression level
|
||||||
strategy: ZStrategy # compression strategy
|
strategy: ZStrategy # compression strategy
|
||||||
memLevel: ZMemLevel # hint for miniz memory consumption
|
memLevel: ZMemLevel # hint for zlib memory consumption
|
||||||
serverNoContextTakeOver: bool
|
serverNoContextTakeOver: bool
|
||||||
clientNoContextTakeOver: bool
|
clientNoContextTakeOver: bool
|
||||||
serverMaxWindowBits: int
|
serverMaxWindowBits: int
|
||||||
|
@ -140,13 +140,15 @@ proc getContextTakeover(opts: DeflateOpts, isServer: bool): bool =
|
||||||
opts.clientNoContextTakeOver
|
opts.clientNoContextTakeOver
|
||||||
|
|
||||||
proc decompressInit(ext: DeflateExt) =
|
proc decompressInit(ext: DeflateExt) =
|
||||||
# decompression using `client_` prefixed config
|
# server decompression using `client_` prefixed config
|
||||||
|
# client decompression using `server_` prefixed config
|
||||||
let windowBits = getWindowBits(ext.opts, not ext.opts.isServer)
|
let windowBits = getWindowBits(ext.opts, not ext.opts.isServer)
|
||||||
doAssert(ext.decompCtx.inflateInit2(windowBits) == Z_OK)
|
doAssert(ext.decompCtx.inflateInit2(windowBits) == Z_OK)
|
||||||
ext.decompCtxState = ContextState.Initialized
|
ext.decompCtxState = ContextState.Initialized
|
||||||
|
|
||||||
proc compressInit(ext: DeflateExt) =
|
proc compressInit(ext: DeflateExt) =
|
||||||
# compression using `server_` prefixed config
|
# server compression using `server_` prefixed config
|
||||||
|
# client compression using `client_` prefixed config
|
||||||
let windowBits = getWindowBits(ext.opts, ext.opts.isServer)
|
let windowBits = getWindowBits(ext.opts, ext.opts.isServer)
|
||||||
doAssert(ext.compCtx.deflateInit2(
|
doAssert(ext.compCtx.deflateInit2(
|
||||||
level = ext.opts.level,
|
level = ext.opts.level,
|
||||||
|
@ -261,7 +263,8 @@ method decode(ext: DeflateExt, frame: Frame): Future[Frame] {.async.} =
|
||||||
frame.mask = false # clear mask flag, decompressed content is not masked
|
frame.mask = false # clear mask flag, decompressed content is not masked
|
||||||
|
|
||||||
if frame.fin:
|
if frame.fin:
|
||||||
# decompression using `client_` prefixed config
|
# server decompression using `client_` prefixed config
|
||||||
|
# client decompression using `server_` prefixed config
|
||||||
let noContextTakeover = getContextTakeover(ext.opts, not ext.opts.isServer)
|
let noContextTakeover = getContextTakeover(ext.opts, not ext.opts.isServer)
|
||||||
if noContextTakeover:
|
if noContextTakeover:
|
||||||
doAssert(ext.decompCtx.inflateReset() == Z_OK)
|
doAssert(ext.decompCtx.inflateReset() == Z_OK)
|
||||||
|
@ -308,7 +311,8 @@ method encode(ext: DeflateExt, frame: Frame): Future[Frame] {.async.} =
|
||||||
frame.consumed = 0
|
frame.consumed = 0
|
||||||
|
|
||||||
if frame.fin:
|
if frame.fin:
|
||||||
# compression using `server_` prefixed config
|
# server compression using `server_` prefixed config
|
||||||
|
# client compression using `client_` prefixed config
|
||||||
let noContextTakeover = getContextTakeover(ext.opts, ext.opts.isServer)
|
let noContextTakeover = getContextTakeover(ext.opts, ext.opts.isServer)
|
||||||
if noContextTakeover:
|
if noContextTakeover:
|
||||||
doAssert(ext.compCtx.deflateReset() == Z_OK)
|
doAssert(ext.compCtx.deflateReset() == Z_OK)
|
||||||
|
|
Loading…
Reference in New Issue