def _conn_request(self, conn, request_uri, method, body, headers):
# Reconstruct the full uri from the connection object.
if isinstance(conn, httplib2.HTTPSConnectionWithTimeout):
scheme = 'https'
else:
scheme = 'http'
host = conn.host
# Reformat IPv6 hosts.
if _is_ipv6(host):
host = '[{}]'.format(host)
full_uri = '{}://{}:{}{}'.format(
scheme, host, conn.port, request_uri)
decode = True if method != 'HEAD' else False
try:
urllib3_response = self.pool.request(
method,
full_uri,
body=body,
headers=headers,
redirect=False,
retries=urllib3.Retry(total=False, redirect=0),
timeout=urllib3.Timeout(total=self.timeout),
decode_content=decode)
response = _map_response(urllib3_response, decode=decode)
content = urllib3_response.data
except Exception as e:
raise _map_exception(e)
return response, content
评论列表
文章目录