Skip to content
This repository was archived by the owner on May 16, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion kubernetes/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ def __init__(self, status=None, reason=None, http_resp=None):
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
# urllib3 2.0+ removed getheaders() in favor of the headers attribute.
try:
self.headers = http_resp.getheaders()
except AttributeError:
# Fallback for urllib3 >= 2.0
self.headers = getattr(http_resp, 'headers', None)
else:
self.status = status
self.reason = reason
Expand Down
5 changes: 4 additions & 1 deletion kubernetes/client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def __init__(self, resp):

def getheaders(self):
"""Returns a dictionary of the response headers."""
return self.urllib3_response.getheaders()
# urllib3 2.0+ removed getheaders() in favor of the headers attribute.
# Use getattr to support both old and new urllib3 versions.
return getattr(self.urllib3_response, 'getheaders',
lambda: self.urllib3_response.headers)()

def getheader(self, name, default=None):
"""Returns a given response header."""
Expand Down