Accept any sequence of header pairs, not just list - #204
Conversation
Callers shouldn't have to copy a tuple or h11 headers object into a list.
|
CI is green on tests; the remaining mark is |
Tuple-backed header sequences exercise the list() conversions added when Headers widened beyond list.
|
Pushed Sequence-backed header tests (tuple as well as list) for the |
The two loops still append into a list. After the walk, the result is Headers, which is what Request and AcceptConnection store.
| ) | ||
| upgrade_request = h11.Request(method=b"GET", target=path, headers=headers) | ||
| upgrade_request = h11.Request( | ||
| method=b"GET", target=path, headers=list(headers), |
There was a problem hiding this comment.
Is explicitly converting to a list here necessary? From what I see in h11 Request and h11, all sequences are normalized and validated anyway.
There was a problem hiding this comment.
It was not. h11 already walks any sequence of pairs in normalize_and_validate, so the extra list() was just a copy.
375ecbf passes headers through, and concatenates extra headers with unpacking. _reject still copies to a list because it appends content-length.
h11 already iterates and validates any sequence of pairs, so the extra copy was only noise.
We only iterate header pairs. Typing them as
listmeant a tuple orh11.Headersneeded a pointlesslist(...)copy.Fixes #173