使用nahpack的Python HPACK库
项目描述
nahpackpy是一个HTTP/2 RFC 7541 HPACK库。它封装了Rust nahpack库。
使用方法
>>> from nahpackpy import Decoder
>>> decoder = Decoder()
>>> headers = decoder.decode_block(
b'\x82\x86\x84A\x8c\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff'
)
>>> for header in headers:
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')
>>> from nahpackpy import Encoder
>>> 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的“Nightly”通道。从rust-lang.org下载一个包。
然后,通过运行make创建一个wheel,其中包含编译后的共享库。或者,运行python setup.py install在当前环境中安装。
杂项
nahpackpy遵循Mozilla公共许可证,版本2.0。
项目详情
关闭
nahpackpy-0.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 104226e27346b016fa281cd1509da5aff8f9264e363bfec2c10198a96dcf06c0 |
|
MD5 | 0a477774466a1753c69ad84e8a7bb02f |
|
BLAKE2b-256 | 748941b8bf9559a75e8c02d94fe378559c8ed5a3e996ee78ddf56eb21084f4f7 |