iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
👻
[Python] Compressing Headers into QPACK Format with pylsqpack
Install pylsqpack with pip3
pip3 install pylsqpack
Paste the script
test.py
from pylsqpack import Encoder, Decoder
headers = [(b':method', b'GET'), (b':scheme', b'https'),
(b':path', b'/resource'), (b':authority', b'example.org')]
print(headers)
e = Encoder()
encoded = e.encode(0, headers)
print(encoded[1])
d = Decoder(1000, 1000)
ret = d.feed_header(20, encoded[1])
print(ret[1])
The results are as follows
[(b':method', b'GET'), (b':scheme', b'https'), (b':path', b'/resource'), (b':authority', b'example.org')]
b'\x00\x00\xd1\xd7Q\x87b\xc2\xa0\xf6\xd8B\xffP\x88/\x91\xd3]\x05\\\xf6M'
[(b':method', b'GET'), (b':scheme', b'https'), (b':path', b'/resource'), (b':authority', b'example.org')]
Discussion