def http_connection(self):
conn = None
xs_url = urllib.parse.urlparse(self.url)
LOG.debug("Creating http(s) connection to %s", self.url)
if xs_url.scheme == 'http':
conn = http_client.HTTPConnection(xs_url.netloc)
elif xs_url.scheme == 'https':
conn = http_client.HTTPSConnection(xs_url.netloc)
conn.connect()
try:
yield conn
finally:
conn.close()
评论列表
文章目录