[New-bugs-announce] [issue14684] zlib set dictionary support inflateSetDictionary
report at bugs.python.org
Fri Apr 27 22:49:09 CEST 2012
New submission from Sam Rushing <rushing.sam at gmail.com>:
Google's SPDY protocol requires the use of a pre-defined compression dictionary. The current zlib module doesn't expose the two functions for setting the dictionary.
This patch is minimal in the sense that it only exposes the two functions, but unfortunately the sequence of zlib calls required is clumsy: a call to inflate() must fail first (with an error of Z_NEED_DICT):
zdict = b"thequickbrownfoxjumped\x00"
c = zlib.compressobj()
cd = c.compress (b"the quick brown fox jumped over the candlestick")
cd += c.flush()
d = zlib.decompressobj()
print (d.decompress (cd))
except zlib.error as what:
if what.args.startswith ('Error 2 '):
Obviously a better way to catch/match Z_NEED_DICT would be nice.
A much nicer solution would allow you to associate the dictionary at creation time, rather than having to wait for an error condition. I can only guess that the zlib authors designed it that way for a reason?
components: Extension Modules
title: zlib set dictionary support inflateSetDictionary
versions: Python 3.4
Added file: http://bugs.python.org/file25387/zlib_set_dictionary.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce