Change return type of HTTPResponse.getheaders() to match CPython
MODIFY
src/urllib3/response.py
src/urllib3/response.py
@@ -317,8 +317,8 @@ class BaseHTTPResponse(io.IOBase):
return len(temp)
# Compatibility methods for http.client.HTTPResponse
- def getheaders(self) -> typing.MutableMapping[str, str]:
- return self.headers
+ def getheaders(self) -> typing.List[typing.Tuple[str, str]]:
+ return list(self.headers.items())
def getheader(
self, name: str, default: typing.Optional[str] = None

MODIFY
test/test_response.py
test/test_response.py
@@ -54,7 +54,7 @@ class TestLegacyResponse:
def test_getheaders(self):
headers = {"host": "example.com"}
r = HTTPResponse(headers=headers)
- assert r.getheaders() == headers
+ assert r.getheaders() == [("host", "example.com")]
def test_getheader(self):
headers = {"host": "example.com"}

Change return type of HTTPResponse.getheaders() to match CPython