response.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:api-gateway-demo-sign-python 作者: aliyun 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号