def from_response(response, method, url):
req_id = response.headers.get("<STR_LIT>")<EOL>if not req_id:<EOL><INDENT>req_id = response.headers.get("<STR_LIT>")<EOL><DEDENT>kwargs = {<EOL>"<STR_LIT>": response.status_code,<EOL>"<STR_LIT>": response,<EOL>"<STR_LIT>": method,<EOL>"<STR_LIT:url>": url,<EOL>"<STR_LIT>": req_id,<EOL>}<EOL>if "<STR_LIT>" in response.headers:<EOL><INDENT>kwargs["<STR_LIT>"] = response.headers["<STR_LIT>"]<EOL><DEDENT>content_type = response.headers.get("<STR_LIT:Content-Type>", "<STR_LIT>")<EOL>if content_type.startswith("<STR_LIT:application/json>"):<EOL><INDENT>try:<EOL><INDENT>body = response.json()<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if isinstance(body, dict):<EOL><INDENT>error = body.get(list(body)[<NUM_LIT:0>])<EOL>if isinstance(error, dict):<EOL><INDENT>kwargs["<STR_LIT:message>"] = (error.get("<STR_LIT:message>") or<EOL>error.get("<STR_LIT>"))<EOL>kwargs["<STR_LIT>"] = (error.get("<STR_LIT>") or<EOL>six.text_type(body))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif content_type.startswith("<STR_LIT>"):<EOL><INDENT>kwargs["<STR_LIT>"] = response.text<EOL><DEDENT>try:<EOL><INDENT>cls = _code_map[response.status_code]<EOL><DEDENT>except KeyError:<EOL><INDENT>if <NUM_LIT> <= response.status_code < <NUM_LIT>:<EOL><INDENT>cls = HttpServerError<EOL><DEDENT>elif <NUM_LIT> <= response.status_code < <NUM_LIT>:<EOL><INDENT>cls = HTTPClientError<EOL><DEDENT>else:<EOL><INDENT>cls = HttpError<EOL><DEDENT><DEDENT>return cls(**kwargs)<EOL>
Returns an instance of :class:`HttpError` or subclass based on response.

    :param response: instance of `requests.Response` class
    :param method: HTTP method used for request
    :param url: URL used for request