Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def request(method, address, session=None,
params=None, headers=None, cookies=None, data=None, json=None, allow_redirects=False, timeout=30):
"""
:param method: str
:param address: str
:return: response
:rtype: HTTPResponse
"""
http.log.info("Request: %s %s", method, address)
msg = "Request: params=%r, headers=%r, cookies=%r, data=%r, json=%r, allow_redirects=%r, timeout=%r"
http.log.debug(msg, params, headers, cookies, data, json, allow_redirects, timeout)
if session is None:
session = requests.Session()
request = requests.Request(method, address,
params=params, headers=headers, cookies=cookies, json=json, data=data)
prepared = request.prepare()
response = session.send(prepared, allow_redirects=allow_redirects, timeout=timeout)
http.log.info("Response: %s %s", response.status_code, response.reason)
http.log.debug("Response headers: %r", response.headers)
http.log.debug("Response cookies: %r", dict(response.cookies))
http.log.debug('Response content: \n%s', response.content)
wrapped_response = HTTPResponse.from_py_response(response)
recorder.record_http_request(method, address, prepared, wrapped_response, session)
return wrapped_response
:param method: str
:param address: str
:return: response
:rtype: HTTPResponse
"""
http.log.info("Request: %s %s", method, address)
msg = "Request: params=%r, headers=%r, cookies=%r, data=%r, json=%r, allow_redirects=%r, timeout=%r"
http.log.debug(msg, params, headers, cookies, data, json, allow_redirects, timeout)
if session is None:
session = requests.Session()
request = requests.Request(method, address,
params=params, headers=headers, cookies=cookies, json=json, data=data)
prepared = request.prepare()
response = session.send(prepared, allow_redirects=allow_redirects, timeout=timeout)
http.log.info("Response: %s %s", response.status_code, response.reason)
http.log.debug("Response headers: %r", response.headers)
http.log.debug("Response cookies: %r", dict(response.cookies))
http.log.debug('Response content: \n%s', response.content)
wrapped_response = HTTPResponse.from_py_response(response)
recorder.record_http_request(method, address, prepared, wrapped_response, session)
return wrapped_response