def get_https_response(self):
try:
self.__port = 443
self.__connection = httplib.HTTPSConnection(self.parse_host(), self.__port,
cert_file=self.__cert_file,
key_file=self.__key_file)
self.__connection.connect()
post_data = None
if self.get_content_type() == constant.CONTENT_TYPE_FORM and self.get_body():
post_data = urllib.urlencode(self.get_body())
else:
post_data = self.get_body()
self.__connection.request(method=self.get_method(), url=self.get_url(), body=post_data,
headers=self.get_headers())
response = self.__connection.getresponse()
return response.status, response.getheaders(), response.read()
except Exception as e:
return None, None, None
finally:
self.__close_connection()
评论列表
文章目录