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

use json() method of Response object #238

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ottonomy
Copy link
Collaborator

@ottonomy ottonomy commented Dec 1, 2020

We discovered a couple cases where the requests library didn't properly handle certain characters in JSON in UTF-8 when response.text was used, but we found that when a UTF-8 charset was forced on a response object, the resulting data was correctly represented in python unicode strings.

Turns out the responses library has a better handling of this with some better charset detection that is compatible with json built into its Response.json() method. Thanks @jcreed-csky for the contribution.

This PR updates the code to use json() method of Response object to resolve issues around content-type encoding: prevents encoding errors / throws same error as json.loads

…on content-type encoding; prevents encoding errors / throws same error as json.loads
@ottonomy ottonomy requested a review from mumitr0ll December 1, 2020 01:11
Copy link
Contributor

@amiller-ims amiller-ims left a comment

Choose a reason for hiding this comment

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

Nice find!

@frgray frgray deleted the bugfix/json-response-encoding branch August 1, 2022 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants