|
16 | 16 | HPACKDecodingError, HPACKEncodingError, ProtocolError |
17 | 17 | ) |
18 | 18 | from hyper.http20.window import FlowControlManager |
19 | | -from hyper.http20.util import combine_repeated_headers, split_repeated_headers |
| 19 | +from hyper.http20.util import ( |
| 20 | + combine_repeated_headers, split_repeated_headers, h2_safe_headers |
| 21 | +) |
20 | 22 | from hyper.compat import zlib_compressobj |
21 | 23 | from hyper.contrib import HTTP20Adapter |
22 | 24 | import errno |
@@ -1011,20 +1013,6 @@ def test_putheader_puts_headers(self): |
1011 | 1013 | ('name', 'value'), |
1012 | 1014 | ] |
1013 | 1015 |
|
1014 | | - def test_putheader_ignores_connection(self): |
1015 | | - c = HTTP20Connection("www.google.com") |
1016 | | - |
1017 | | - c.putrequest('GET', '/') |
1018 | | - c.putheader('Connection', 'keep-alive') |
1019 | | - s = c.recent_stream |
1020 | | - |
1021 | | - assert s.headers == [ |
1022 | | - (':method', 'GET'), |
1023 | | - (':scheme', 'https'), |
1024 | | - (':authority', 'www.google.com'), |
1025 | | - (':path', '/'), |
1026 | | - ] |
1027 | | - |
1028 | 1016 | def test_endheaders_sends_data(self): |
1029 | 1017 | frames = [] |
1030 | 1018 |
|
@@ -2048,6 +2036,32 @@ def test_nghttp2_installs_correctly(self): |
2048 | 2036 |
|
2049 | 2037 | assert True |
2050 | 2038 |
|
| 2039 | + def test_stripping_connection_header(self): |
| 2040 | + headers = [('one', 'two'), ('connection', 'close')] |
| 2041 | + stripped = [('one', 'two')] |
| 2042 | + |
| 2043 | + assert h2_safe_headers(headers) == stripped |
| 2044 | + |
| 2045 | + def test_stripping_related_headers(self): |
| 2046 | + headers = [ |
| 2047 | + ('one', 'two'), ('three', 'four'), ('five', 'six'), |
| 2048 | + ('connection', 'close, three, five') |
| 2049 | + ] |
| 2050 | + stripped = [('one', 'two')] |
| 2051 | + |
| 2052 | + assert h2_safe_headers(headers) == stripped |
| 2053 | + |
| 2054 | + def test_stripping_multiple_connection_headers(self): |
| 2055 | + headers = [ |
| 2056 | + ('one', 'two'), ('three', 'four'), ('five', 'six'), |
| 2057 | + ('connection', 'close'), |
| 2058 | + ('connection', 'three, five') |
| 2059 | + ] |
| 2060 | + stripped = [('one', 'two')] |
| 2061 | + |
| 2062 | + assert h2_safe_headers(headers) == stripped |
| 2063 | + |
| 2064 | + |
2051 | 2065 | # Some utility classes for the tests. |
2052 | 2066 | class NullEncoder(object): |
2053 | 2067 | @staticmethod |
|
0 commit comments