def BadResponse(body, request, status_code=None,
                    headers=None):
        """
        Construct a Bad HTTP response (defined in DEFAULT_BAD_RESPONSE_CODE)

        :param body: The body of the response
        :type  body: ``str``

        :param request: The HTTP request
        :type  request: :class:`requests.Request`

        :param status_code: The return status code, defaults
            to DEFAULT_GOOD_STATUS_CODE if not specified
        :type  status_code: ``int``

        :param headers: Response headers, defaults to
            DEFAULT_RESPONSE_HEADERS if not specified
        :type  headers: ``dict``

        :rtype: :class:`requests.Response`
        :returns: a Response object
        """
        response = Response()
        response.url = request.url
        response.raw = BytesIO(body)
        if status_code:
            response.status_code = status_code
        else:
            response.status_code = DEFAULT_BAD_STATUS_CODE
        if headers:
            response.headers = headers
        else:
            response.headers = DEFAULT_RESPONSE_HEADERS
        response.request = request
        response._content = body
        return response
def BadResponse ( body , request , status_code = None , headers = None ) : response = Response ( ) response . url = request . url response . raw = BytesIO ( body ) if status_code : response . status_code = status_code else : response . status_code = DEFAULT_BAD_STATUS_CODE if headers : response . headers = headers else : response . headers = DEFAULT_RESPONSE_HEADERS response . request = request response . _content = body return response
Construct a Bad HTTP response (defined in DEFAULT_BAD_RESPONSE_CODE)

        :param body: The body of the response
        :type  body: ``str``

        :param request: The HTTP request
        :type  request: :class:`requests.Request`

        :param status_code: The return status code, defaults
            to DEFAULT_GOOD_STATUS_CODE if not specified
        :type  status_code: ``int``

        :param headers: Response headers, defaults to
            DEFAULT_RESPONSE_HEADERS if not specified
        :type  headers: ``dict``

        :rtype: :class:`requests.Response`
        :returns: a Response object