Beispiel #1
0
    def get_response_body(self, resp: HTTPResponse,
                          resp_encoding: str) -> HTTPResponse:
        """
        构造r.text
        :param resp:
        :param resp_encoding:
        :return:
        """
        resp._resp_charset = self._get_charset(
            resp.headers.get("Content-Type", ''), resp_encoding)

        # 减少不必要的转换
        type(resp).text = property(
            lambda x: x.body.decode(x._resp_charset, errors='ignore'))
        return resp