Skip to content

Commit 54bef8f

Browse files
committed
Fix header retrieval in REST client
add support of `.headers` for urlib3 > 2.0.0
1 parent 3ef6286 commit 54bef8f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kubernetes/client/rest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ def __init__(self, resp):
4141

4242
def getheaders(self):
4343
"""Returns a dictionary of the response headers."""
44+
if hasattr(self.urllib3_response, 'headers'):
45+
return self.urllib3_response.headers.items()
4446
return self.urllib3_response.getheaders()
4547

4648
def getheader(self, name, default=None):
4749
"""Returns a given response header."""
50+
if hasattr(self.urllib3_response, 'headers'):
51+
return self.urllib3_response.headers.get(name, default)
4852
return self.urllib3_response.getheader(name, default)
4953

5054

0 commit comments

Comments
 (0)