def _read_response(self, curl_output):

        # Build a new response.
        self.response = Response()

        # Read the metadata appended to the end of the request.
        meta = curl_output[curl_output.rfind(b"\n\n"):]
        meta = meta.decode("ascii")
        meta = json.loads(meta)
        size_header = meta["size_header"]
        size_download = meta["size_download"]

        # Extract the headers and body
        headers = curl_output[0:size_header]
        body = curl_output[size_header:size_header + size_download]

        # Parse the headers as ASCII
        headers = headers.decode("ascii")
        headers = headers.split("\r\n")

        # Consume blank lines and CONTINUE status lines from headers
        for i in range(len(headers)):
            header = headers[i].upper()
            if header and "100 CONTINUE" not in header:
                headers = headers[i:]
                break

        # Read the first line as the status line.
        status_line = headers[0]
        try:
            (protocol, status, reason) = status_line.split(" ", 2)
        except __HOLE__:
            print(curl_output)
            self.message = "Unable to read response. " \
                           "Response may have times out."
            self.success = False
            return

        self.response.protocol = protocol
        self.response.status = int(status)
        self.response.reason = reason

        # Add each header
        for header in headers[1:]:
            if ":" in header:
                (key, value) = header.split(":", 1)
                self.response.headers.append((key.strip(), value.strip()))

        # Read the body
        self.response.body = self._read_body(body)
        self.success = True
dataset/ETHPy150Open pjdietz/rester-sublime-http-client/rester/http.py/CurlRequestThread._read_response