def get_response_object()

in aliyun-python-sdk-core/aliyunsdkcore/http/http_response.py [0:0]


    def get_response_object(self):
        current_protocol = 'https://' if self.get_ssl_enabled() else 'http://'
        host = self.get_host()
        if host.startswith('https://') or\
                not host.startswith('https://') and current_protocol == 'https://':
            port = ':%s' % self.__port if self.__port != 80 and self.__port != 443 else ''
        else:
            port = ':%s' % self.__port if self.__port != 80 else ''

        if host.startswith('http://') or host.startswith('https://'):
            url = host + port + self.get_url()
        else:
            url = current_protocol + host + port + self.get_url()

        self.__session.cookies.clear()

        req = Request(method=self.get_method(), url=url,
                      data=self.get_body(),
                      headers=self.get_headers(),
                      )
        prepped = self.__session.prepare_request(req)
        if not self.proxy:
            proxy_https = os.environ.get('HTTPS_PROXY') or os.environ.get(
                'https_proxy')
            proxy_http = os.environ.get(
                'HTTP_PROXY') or os.environ.get('http_proxy')

            self.proxy = {}
            if proxy_http:
                self.proxy['http'] = proxy_http
            if proxy_https:
                self.proxy['https'] = proxy_https

        response = self.__session.send(
            prepped,
            proxies=self.proxy,
            timeout=(self.__connect_timeout, self.__read_timeout),
            allow_redirects=False,
            verify=self.get_verify_value()
        )

        http_debug = os.environ.get('DEBUG')

        if http_debug is not None and http_debug.lower() == 'sdk':
            # http debug information
            self.do_http_debug(prepped, response)

        return response.status_code, response.headers, response.content