import zlib draft2_dict = ( b"optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" b"languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" b"f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" b"-agent10010120020120220320420520630030130230330430530630740040140240340440" b"5406407408409410411412413414415416417500501502503504505accept-rangesageeta" b"glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" b"ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" b"sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" b"oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" b"ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" b"pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" b"ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" b".1statusversionurl\x00" # NOTE: the \x00 at the end ) d = zlib.decompressobj (dict=draft2_dict) def test (data, expect): assert (d.decompress (data) == expect) test (b'8\xea\xdf\xa2Q\xb2b\xe0f`\x83\xa4\x17\x06{\xb8\x0bu0,\xd6\xae@\x17\xcd\xcd\xb1.\xb45\xd0\xb3\xd4\xd1\xd2\xd7\x02\xb3,\x18\xf8Ps,\x83\x9cg\xb0?\xd4=:`\x07\x81\xd5\x99\xeb@\xd4\x1b3\xf0\xa3\xe5i\x06A\x90\x8bu\xa0N\xd6)NI\xce\x80\xab\x81%\x03\x06\xbe\xd4<\xdd\xd0`\x9d\xd4<\xa8\xa5,\xa0<\xce\xc0ihd\xaeg\x00\x84\x86\x0cl\xb9\xc0b%?\x85\x81\xd9\xdd5\x84\x81\x1d\x9a3\x19$2JJ\n\x8a\xad\xf4\xf5\xe1\n\xf5!a\xc1\xc0V\x0cL\xac\xb9\xa9\x0c\xac`\x15\x0c\xcc\xa0Pa\x87Ir!24C\xa9o>@U\x9999\x89\xfa\xa6z\x06\n\x1a\xbe\x89\xc9\x99y%\xf9\xc5\x19\xd6\n\x9e\xc04\x96\xa3\x00\x14P\xf0\x0fV\x88P04\x887\x8f7\xd6Tp\x04\x06Wjxj\x92wf\x89\xbe\xa9\xb1\x99\x9e\xa9\x82\x86\xb7G\x88\xaf\x8f\x8eBNfv\xaa\x82{jrv\xbe\xa6\x82s\x06\xb0\x9cJ\xd57\xb4\x04\xb9\t\x98\xd1\xf5\x8c\r\x14\x82\x13\xd3\x12\x8b2!\x9a\x18\xd8\xa1\xb1\xc5\xc0\x01\x8bD\x00\x00\x00\x00\xff\xff', b'\x00\x0b\x00\x06accept\x00?text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\x00\x0eaccept-charset\x00\x1eISO-8859-1,utf-8;q=0.7,*;q=0.3\x00\x0faccept-encoding\x00\x11gzip,deflate,sdch\x00\x0faccept-language\x00\x0een-US,en;q=0.8\x00\x04host\x00\t127.0.0.1\x00\x06method\x00\x03GET\x00\x07referer\x00\x18https://127.0.0.1/status\x00\x06scheme\x00\x05https\x00\x03url\x00\x07/status\x00\nuser-agent\x00uMozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.30 Safari/536.5\x00\x07version\x00\x08HTTP/1.1') test (b'b\xe0\x19\xe2q\xc6\x8bR@0pB\x93\xb1\xad\xc1H\x8cM\x00\x00\x00\x00\xff\xff', b'\x00\x0c\x00\x06accept\x00?text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\x00\x0eaccept-charset\x00\x1eISO-8859-1,utf-8;q=0.7,*;q=0.3\x00\x0faccept-encoding\x00\x11gzip,deflate,sdch\x00\x0faccept-language\x00\x0een-US,en;q=0.8\x00\rcache-control\x00\tmax-age=0\x00\x04host\x00\t127.0.0.1\x00\x06method\x00\x03GET\x00\x07referer\x00\x18https://127.0.0.1/status\x00\x06scheme\x00\x05https\x00\x03url\x00\x07/status\x00\nuser-agent\x00uMozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.30 Safari/536.5\x00\x07version\x00\x08HTTP/1.1') test (b'b\xe0\x82\xc7&30^\x06c.\xc2\x16\xa8<\xfai\x89e\x99\xc0(\xd4\x03\x12\x833d\x01\x00\x00\x00\xff\xff', b'\x00\n\x00\x06accept\x00\x03*/*\x00\x0eaccept-charset\x00\x1eISO-8859-1,utf-8;q=0.7,*;q=0.3\x00\x0faccept-encoding\x00\x11gzip,deflate,sdch\x00\x0faccept-language\x00\x0een-US,en;q=0.8\x00\x04host\x00\t127.0.0.1\x00\x06method\x00\x03GET\x00\x06scheme\x00\x05https\x00\x03url\x00\x0c/favicon.ico\x00\nuser-agent\x00uMozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.30 Safari/536.5\x00\x07version\x00\x08HTTP/1.1')