Python urllib3.response.HTTPResponse.from_httplib() Examples

The following are 1 code examples of urllib3.response.HTTPResponse.from_httplib(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urllib3.response.HTTPResponse , or try the search function .
Example #1
Source File: core.py    From requests-racer with GNU General Public License v3.0 6 votes vote down vote up
def _process_responses(self, requests):
        for request, conn, _, response in requests:
            if response.status_code == 999:
                # skip processing the response if we failed to finish the
                # request in the first place.
                continue

            try:
                raw_response = conn.getresponse()
                urllib3_reponse = HTTPResponse.from_httplib(
                    raw_response,
                    # pool=conn, # TODO?
                    connection=conn,
                    preload_content=False,
                    decode_content=False
                )
            except:
                # HACK: see below.
                response.__init__()
                self.build_exception_response_into(
                    response, request, sys.exc_info()
                )
            else:
                # HACK: we re-initialize the response that we originally handed
                # out to the user because there are a bunch of properties that
                # cache various things and cleaning those up would be too much
                # of a hassle.
                response.__init__()
                self.build_response_into(response, request, urllib3_reponse)

            # TODO closing connection