#NEWLINE# def negotiate_decoder( content_type = None , decoders = None ) : #NEWLINE# #INDENT# "\n    Given the value of a 'Content-Type' header, return the appropriate\n    codec registered to decode the request content.\n    " #NEWLINE# if ( decoders is None ) : #NEWLINE# #INDENT# decoders = default_decoders #NEWLINE# #UNINDENT# if ( content_type is None ) : #NEWLINE# #INDENT# return decoders [ 0 ] #NEWLINE# #UNINDENT# content_type = content_type . split ( ';' ) [ 0 ] . strip ( ) . lower ( ) #NEWLINE# for codec in decoders : #NEWLINE# #INDENT# if ( codec . media_type == content_type ) : #NEWLINE# #INDENT# return codec #NEWLINE# #UNINDENT# #UNINDENT# msg = ( "Unsupported media in Content-Type header '%s'" % content_type ) #NEWLINE# raise UnsupportedContentType ( msg )