Ejemplo n.º 1
0
class AbstractBaseHttpResponse(object):
    """
    Wrapper of Urllib3 HTTPResponse class needed to implement any HttpSdk response class.

    See `Urllib3 <http://urllib3.readthedocs.io/en/latest/user-guide.html#response-content>`_.
    """
    urllib3_response = None
    _cookie = None

    def __init__(self, resp):
        self.urllib3_response = resp

    @property
    def cookie(self):
        if not self._cookie:
            self._cookie = Cookie(self.headers)
        else:
            self._cookie.load_from_headers(self.headers)
        return self._cookie

    @property
    def headers(self):
        """
        Returns a dictionary of the response headers.
        """
        return self.urllib3_response.getheaders()