python-hyper / hpack

HTTP/2 Header Encoding for Python
https://hpack.readthedocs.io/en/latest/
MIT License
72 stars 32 forks source link

fix encoding with generators #263

Closed Kriechi closed 3 years ago

Kriechi commented 3 years ago

Previously we printed a debug message with the headers to encode. This headers iterable could be a generator, which just debug-printed the type information, but not the expected header values within. See https://github.com/python-hyper/hyper-h2/issues/1219.

As potential fix a previous commit simply converted it to a list - which then rendered the generator empty and unusable. The tests didn't cover this yet.

This commit removes the debug-print altogether, because each added header is already debug-printed in the add() function. We add some additional information to this existing debug print and remove the top-level debug-print in the encode() function.

This commit adds a simple test case for passing a generator as headers into encode().

see https://github.com/python-hyper/hpack/commit/da26ef448423872c8e07f9dbea0e67f603510050#commitcomment-41234380 see https://github.com/python-hyper/hyper-h2/issues/1219#issuecomment-669625785

/cc @dimaqq