mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
json errors
This commit is contained in:
@@ -44,6 +44,7 @@ def request(method, url, **kwargs):
|
||||
if session is None:
|
||||
session = sessions.session(config=kwargs.get('config', None))
|
||||
adhoc_session = True
|
||||
# Todo, close sessions after?
|
||||
|
||||
|
||||
return session.request(method=method, url=url, **kwargs)
|
||||
|
||||
+4
-8
@@ -1048,14 +1048,10 @@ class Response(BaseResponse):
|
||||
# a best guess).
|
||||
encoding = guess_json_utf(self.content)
|
||||
if encoding is not None:
|
||||
try:
|
||||
return json.loads(self.content.decode(encoding))
|
||||
except (ValueError, UnicodeDecodeError):
|
||||
pass
|
||||
try:
|
||||
return json.loads(self.text or self.content)
|
||||
except ValueError:
|
||||
return None
|
||||
return json.loads(self.content.decode(encoding))
|
||||
|
||||
return json.loads(self.text or self.content)
|
||||
|
||||
|
||||
@property
|
||||
def links(self):
|
||||
|
||||
Reference in New Issue
Block a user