Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except: # noqa: E722 bare-except
try:
data = response.text
except: # noqa: E722 bare-except
try:
data = response.content
except: # noqa: E722 bare-except
try:
data = response.body
except: # noqa: E722 bare-except
data = None
if request.media_upload:
upload_file = request.media_upload.file_path
return Response(
url=str(response.url),
headers=response.headers,
status_code=response.status_code,
json=json,
data=data,
reason=response.reason_phrase
if getattr(response, "reason_phrase")
else None,
req=request,
download_file=download_file,
upload_file=upload_file,
session_factory=session_factory,
)
except: # noqa: E722 bare-except
try:
data = response.text
except: # noqa: E722 bare-except
try:
data = response.content
except: # noqa: E722 bare-except
try:
data = response.body
except: # noqa: E722 bare-except
data = None
if request.media_upload:
upload_file = request.media_upload.file_path
return Response(
url=str(response.url),
headers=response.headers,
status_code=response.status_code,
json=json,
data=data,
reason=response.reason_phrase
if getattr(response, "reason_phrase")
else None,
req=request,
download_file=download_file,
upload_file=upload_file,
session_factory=session_factory,
)
if response.status != 204: # If no (no content)
try:
json = await response.json()
except (JSONDecodeError, ContentTypeError):
try:
data = await response.text()
except ContentTypeError:
try:
data = await response.read()
except ContentTypeError:
data = None
if request.media_upload:
upload_file = request.media_upload.file_path
return Response(
url=str(response.url),
headers=response.headers,
status_code=response.status,
json=json,
data=data,
reason=response.reason if getattr(response, "reason") else None,
req=request,
download_file=download_file,
upload_file=upload_file,
session_factory=session_factory,
)