Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove checking headers if raw content is returned from rest api #123

Merged
merged 1 commit into from
Oct 22, 2020
Merged
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
4 changes: 1 addition & 3 deletions kubernetes_asyncio/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,15 @@ async def __call_api(
e.body = e.body.decode('utf-8') if six.PY3 else e.body
raise e

content_type = response_data.getheader('content-type')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response_data can be a raw response (aiohttp ClientResponse) if _preload_content is false. The raw response doesn't have methods like getheader, getheaders. This assign is not necessary here and can be done later when preloaded content is processing.


self.last_response = response_data

return_data = response_data

if not _preload_content:
return return_data

if six.PY3 and response_type not in ["file", "bytes"]:
match = None
content_type = response_data.getheader('content-type')
if content_type is not None:
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
encoding = match.group(1) if match else "utf-8"
Expand Down