Example #1
0
    def __init__(self, connection, request, resp):
        self.request = request
        self.connection = connection

        self._resp = resp

        # response infos
        self.headers = resp.headers()
        self.status = resp.status()
        self.status_int = resp.status_code()
        self.version = resp.version()
        self.headerslist = self.headers.items()
        self.location = self.headers.get('location')
        self.final_url = request.url
        self.should_close = not resp.should_keep_alive()

        # cookies
        if 'set-cookie' in self.headers:
            cookie_header = self.headers.get('set-cookie')
            self.cookies = parse_cookie(cookie_header, self.final_url)


        self._closed = False
        self._already_read = False

        if request.method == "HEAD":
            """ no body on HEAD, release the connection now """
            self.connection.release(True)
            self._body = StringIO("")
        else:
            self._body = resp.body_file()
Example #2
0
    def __init__(self, connection, request, resp):
        self.request = request
        self.connection = connection

        self._resp = resp

        # response infos
        self.headers = resp.headers()
        self.status = resp.status()
        self.status_int = resp.status_code()
        self.version = resp.version()
        self.headerslist = self.headers.items()
        self.location = self.headers.get('location')
        self.final_url = request.url
        self.should_close = not resp.should_keep_alive()

        # cookies
        if 'set-cookie' in self.headers:
            cookie_header = self.headers.get('set-cookie')
            self.cookies = parse_cookie(cookie_header, self.final_url)


        self._closed = False
        self._already_read = False

        if request.method == "HEAD":
            """ no body on HEAD, release the connection now """
            self.connection.release(True)
            self._body = StringIO("")
        else:
            self._body = resp.body_file()