Fix compatibility with urllib3 v2.6

urllib3 v2.6 removed `HTTPResponse.getheader(name, default)` in favor of
`HTTPResponse.headers.get(name, default)`, see https://github.com/urllib3/urllib3/pull/3622

Changed from `resp.raw.getheader` to `resp.headers.get` for compatibility.
Fixed `test_response_headers` test to verify getheader() works properly.

Change-Id: Ic0fab4ca6407f5435d87aa02d533f3eb826f5b3b
Signed-off-by: Anthony Roussel <anthony@roussel.dev>
This commit is contained in:
Anthony Roussel
2026-02-23 23:51:43 +01:00
parent 0c73602223
commit ee39a1507f
2 changed files with 2 additions and 1 deletions

View File

@@ -441,7 +441,7 @@ class HTTPConnection:
def getresponse(self):
"""Adapt requests response to httplib interface"""
self.resp.status = self.resp.status_code
old_getheader = self.resp.raw.getheader
old_getheader = self.resp.headers.get
def _decode_header(string):
if string is None:

View File

@@ -2003,6 +2003,7 @@ class TestHTTPConnection(MockHttpTest):
self.assertEqual(
'\u062a-value', resp.getheader('\u062a-UNICODE'))
self.assertEqual('', resp.getheader('empty-header'))
self.assertEqual('"%s"' % EMPTY_ETAG, resp.getheader('etag'))
self.assertEqual(
dict([('\u062a-unicode', '\u062a-value'),
('empty-header', ''),