#NEWLINE# def _format_data_according_to_header( self , session , data , headers ) : #NEWLINE# #INDENT# headers = self . _merge_headers ( session , headers ) #NEWLINE# if ( ( data is not None ) and ( headers is not None ) and ( 'Content-Type' in headers ) and ( not self . _is_json ( data ) ) ) : #NEWLINE# #INDENT# if ( headers [ 'Content-Type' ] . find ( 'application/json' ) != ( - 1 ) ) : #NEWLINE# #INDENT# data = json . dumps ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( headers [ 'Content-Type' ] . find ( 'application/x-www-form-urlencoded' ) != ( - 1 ) ) : #NEWLINE# #INDENT# data = self . _utf8_urlencode ( data ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# data = self . _utf8_urlencode ( data ) #NEWLINE# #UNINDENT# return data