update comments in compression extensions [skip ci]

fixes #14
This commit is contained in:
jangko 2021-06-21 14:01:51 +07:00
parent 5a93ad7867
commit e56447dda3
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 13 additions and 9 deletions

View File

@ -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)