跳转到主要内容

使用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 (36.4 kB 查看哈希值)

上传时间