使用nahpack的python hpack库
nahpackp的Python项目详细描述
nahpackpy是一个HTTP/2RFC 7541 HPACK库它包裹着 锈库。
用法
>>>fromnahpackpyimportDecoder>>>decoder=Decoder()>>>headers=decoder.decode_block(b'\x82\x86\x84A\x8c\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff')>>>forheaderinheaders:print(header)Header(name=b':method',value=b'GET')Header(name=b':scheme',value=b'http')Header(name=b':path',value=b'/')Header(name=b':authority',value=b'www.example.com')
>>>fromnahpackpyimportEncoder>>>encoder=Encoder()>>>encoder.encode_block(((b':method',b'GET'),(b':scheme',b'http'),(b':path',b'/'),(b':authority',b'www.example.com'),))b'\x82\x86\x84A\x8c\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff'
安装
从源代码安装需要使用Rust语言 扩展的编译。需要“夜间”的生锈通道。 从下载包 rust-lang.org
然后,您可以创建一个控制盘,它将包含编译后的共享 库,通过运行make。或者,运行python setup.py install到 在当前环境中安装。
其他
Nahpackpy是根据Mozilla Public License, Version 2.0授权的。