diff --git a/hyper/http20/util.py b/hyper/http20/util.py index ca5547d0..726c4a05 100644 --- a/hyper/http20/util.py +++ b/hyper/http20/util.py @@ -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] diff --git a/test/test_hyper.py b/test/test_hyper.py index b826c63c..dc86385a 100644 --- a/test/test_hyper.py +++ b/test/test_hyper.py @@ -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