diff --git a/hyper/http20/util.py b/hyper/http20/util.py index b116d095..ca5547d0 100644 --- a/hyper/http20/util.py +++ b/hyper/http20/util.py @@ -52,9 +52,9 @@ def h2_safe_headers(headers): """ stripped = { i.lower().strip() - for k, v in headers if k == 'connection' - for i in v.split(',') + for k, v in headers if k == b'connection' + for i in v.split(b',') } - stripped.add('connection') + stripped.add(b'connection') return [header for header in headers if header[0] not in stripped] diff --git a/test/test_hyper.py b/test/test_hyper.py index 59d354c7..6a18d592 100644 --- a/test/test_hyper.py +++ b/test/test_hyper.py @@ -1176,27 +1176,27 @@ def test_nghttp2_installs_correctly(self): assert True def test_stripping_connection_header(self): - headers = [('one', 'two'), ('connection', 'close')] - stripped = [('one', 'two')] + headers = [(b'one', b'two'), (b'connection', b'close')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped def test_stripping_related_headers(self): headers = [ - ('one', 'two'), ('three', 'four'), ('five', 'six'), - ('connection', 'close, three, five') + (b'one', b'two'), (b'three', b'four'), (b'five', b'six'), + (b'connection', b'close, three, five') ] - stripped = [('one', 'two')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped def test_stripping_multiple_connection_headers(self): headers = [ - ('one', 'two'), ('three', 'four'), ('five', 'six'), - ('connection', 'close'), - ('connection', 'three, five') + (b'one', b'two'), (b'three', b'four'), (b'five', b'six'), + (b'connection', b'close'), + (b'connection', b'three, five') ] - stripped = [('one', 'two')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped