#NEWLINE# def create_response( request , **kwargs ) : #NEWLINE# #INDENT# '\n    :param int status_code: The status code to return upon a successful\n        match. Defaults to 200.\n    :param HTTPResponse raw: A HTTPResponse object to return upon a\n        successful match.\n    :param io.IOBase body: An IO object with a read() method that can\n        return a body on successful match.\n    :param bytes content: A byte string to return upon a successful match.\n    :param unicode text: A text string to return upon a successful match.\n    :param object json: A python object to be converted to a JSON string\n        and returned upon a successful match.\n    :param dict headers: A dictionary object containing headers that are\n        returned upon a successful match.\n    :param CookieJar cookies: A cookie jar with cookies to set on the\n        response.\n    ' #NEWLINE# connection = kwargs . pop ( 'connection' , _FakeConnection ( ) ) #NEWLINE# _check_body_arguments ( ** kwargs ) #NEWLINE# raw = kwargs . pop ( 'raw' , None ) #NEWLINE# body = kwargs . pop ( 'body' , None ) #NEWLINE# content = kwargs . pop ( 'content' , None ) #NEWLINE# text = kwargs . pop ( 'text' , None ) #NEWLINE# json = kwargs . pop ( 'json' , None ) #NEWLINE# encoding = None #NEWLINE# if ( content and ( not isinstance ( content , six . binary_type ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Content should be a callback or binary data' ) #NEWLINE# #UNINDENT# if ( text and ( not isinstance ( text , six . string_types ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Text should be a callback or string data' ) #NEWLINE# #UNINDENT# if ( json is not None ) : #NEWLINE# #INDENT# text = jsonutils . dumps ( json ) #NEWLINE# #UNINDENT# if ( text is not None ) : #NEWLINE# #INDENT# encoding = 'utf-8' #NEWLINE# content = text . encode ( encoding ) #NEWLINE# #UNINDENT# if ( content is not None ) : #NEWLINE# #INDENT# body = six . BytesIO ( content ) #NEWLINE# #UNINDENT# if ( not raw ) : #NEWLINE# #INDENT# raw = HTTPResponse ( status = kwargs . get ( 'status_code' , _DEFAULT_STATUS ) , headers = kwargs . get ( 'headers' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , reason = kwargs . get ( 'reason' ) , body = ( body or six . BytesIO ( six . b ( '' ) ) ) , decode_content = False , preload_content = False , original_response = compat . _fake_http_response ) #NEWLINE# #UNINDENT# response = _http_adapter . build_response ( request , raw ) #NEWLINE# response . connection = connection #NEWLINE# response . encoding = encoding #NEWLINE# _extract_cookies ( request , response , kwargs . get ( 'cookies' ) ) #NEWLINE# return response