Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Use iter_raw when making headers h2-safe to preserve original headers #390

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions hyper/http20/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ def h2_safe_headers(headers):
for i in v.split(b',')
}
stripped.add(b'connection')

return [header for header in headers if header[0] not in stripped]
if hasattr(headers, 'iter_raw'):
iter_raw = headers.iter_raw()
else:
iter_raw = headers
return [header for header in iter_raw if header[0] not in stripped]
6 changes: 6 additions & 0 deletions test/test_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,12 @@ def test_stripping_multiple_connection_headers(self):

assert h2_safe_headers(headers) == stripped

def test_stripping_headers_leaves_commas_and_space_intact(self):
headers = HTTPHeaderMap(**{'one': 'two, three, four'})
stripped = [(b'one', b'two, three, four')]

assert h2_safe_headers(headers) == stripped

def test_goaway_frame_PROTOCOL_ERROR(self):
f = GoAwayFrame(0)
# Set error code to PROTOCOL_ERROR
Expand Down