New submission from Sam Rushing <rushing....@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): import zlib zdict = b"thequickbrownfoxjumped\x00" c = zlib.compressobj() c.set_dictionary (zdict) cd = c.compress (b"the quick brown fox jumped over the candlestick") cd += c.flush() d = zlib.decompressobj() try: print (d.decompress (cd)) except zlib.error as what: if what.args[0].startswith ('Error 2 '): d.set_dictionary (zdict) print (d.flush()) 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 files: zlib_set_dictionary.patch keywords: patch messages: 159492 nosy: Sam.Rushing priority: normal severity: normal status: open title: zlib set dictionary support inflateSetDictionary type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file25387/zlib_set_dictionary.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14684> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com