Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except KeyError:
content_length = 'No content-length header'
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
elif 'content-length' in response.headers and response.headers['content-length'] != '0':
if response.headers['content-type'] == 'application/zip':
logger.api_response('Zip file')
else:
logger.api_response(response.content.decode('UTF-8'))
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
elif 'content-length' in response.headers and response.headers['content-length'] != '0':
if response.headers['content-type'] == 'application/zip':
logger.api_response('Zip file')
else:
logger.api_response(response.content.decode('UTF-8'))
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
elif 'content-length' in response.headers and response.headers['content-length'] != '0':
if response.headers['content-type'] == 'application/zip':
logger.api_response('Zip file')
else:
logger.api_response(response.content.decode('UTF-8'))
def log_api(method, uri, response):
try:
content_length = response.headers['content-length']
except KeyError:
content_length = 'No content-length header'
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
def log_api(method, uri, response):
try:
content_length = response.headers['content-length']
except KeyError:
content_length = 'No content-length header'
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
elif 'content-length' in response.headers and response.headers['content-length'] != '0':
if response.headers['content-type'] == 'application/zip':
logger.api_response('Zip file')
else:
logger.api_response(response.content.decode('UTF-8'))
def log_api(method, uri, response):
try:
content_length = response.headers['content-length']
except KeyError:
content_length = 'No content-length header'
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
length=content_length)
logger.api_call(log)
if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
try:
import json
response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
except ValueError:
response_info = 'No json response available'
logger.api_response(response_info)
elif 'content-length' in response.headers and response.headers['content-length'] != '0':
if response.headers['content-type'] == 'application/zip':
logger.api_response('Zip file')
else:
logger.api_response(response.content.decode('UTF-8'))