#NEWLINE# def __init__( self , method , uri , body = None , headers = None ) : #NEWLINE# #INDENT# if ( not uri ) : #NEWLINE# #INDENT# raise ValueError ( 'No URI specified for request' ) #NEWLINE# #UNINDENT# self . __method = method #NEWLINE# self . __uri = make_uri ( uri ) #NEWLINE# self . __headers = dict ( ( headers or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if isinstance ( body , ( set , frozenset ) ) : #NEWLINE# #INDENT# body = list ( self ) #NEWLINE# #UNINDENT# if ( body is None ) : #NEWLINE# #INDENT# self . __body = body #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( body , ( dict , list , tuple ) ) : #NEWLINE# #INDENT# self . __headers . setdefault ( 'Content-Type' , 'application/json' ) #NEWLINE# self . __body = json . dumps ( body , cls = JSONEncoder , separators = ',:' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if is_unicode ( body ) : #NEWLINE# #INDENT# self . __headers . setdefault ( 'Content-Type' , 'text/plain; charset=UTF-8' ) #NEWLINE# self . __body = body . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( body , bytes ) : #NEWLINE# #INDENT# self . __headers . setdefault ( 'Content-Type' , 'application/octet-stream' ) #NEWLINE# self . __body = body #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Unsupported type for request body: %s' % body . __class__ . __name__ ) )