def parse_content_type_header(content_type):
 if (';' in content_type):
  split = content_type.split(';')
  media = split[0]
  options = {}
  for pair in split[1:]:
   split_pair = pair.split('=', 1)
   if (len(split_pair) != 2):
    continue
   key = split_pair[0].strip()
   value = split_pair[1].strip()
   options[key] = value
 else:
  media = content_type
  options = {}
 result = (media, options)
 return result

def parse_content_type_header ( content_type ) : if ( ';' in content_type ) : split = content_type . split ( ';' ) media = split [ 0 ] options = { } for pair in split [ 1 : ] : split_pair = pair . split ( '=' , 1 ) if ( len ( split_pair ) != 2 ) : continue key = split_pair [ 0 ] . strip ( ) value = split_pair [ 1 ] . strip ( ) options [ key ] = value else : media = content_type options = { } result = ( media , options ) return result
parse and normalize request content type and return a tuple with the content type and the options .