def parse_content_type(c):
 parts = c.split(';', 1)
 ts = parts[0].split('/', 1)
 if (len(ts) != 2):
  return None
 d = {}
 if (len(parts) == 2):
  for i in parts[1].split(';'):
   clause = i.split('=', 1)
   if (len(clause) == 2):
    d[clause[0].strip()] = clause[1].strip()
 return (ts[0].lower(), ts[1].lower(), d)

def parse_content_type ( c ) : parts = c . split ( ';' , 1 ) ts = parts [ 0 ] . split ( '/' , 1 ) if ( len ( ts ) != 2 ) : return None d = { } if ( len ( parts ) == 2 ) : for i in parts [ 1 ] . split ( ';' ) : clause = i . split ( '=' , 1 ) if ( len ( clause ) == 2 ) : d [ clause [ 0 ] . strip ( ) ] = clause [ 1 ] . strip ( ) return ( ts [ 0 ] . lower ( ) , ts [ 1 ] . lower ( ) , d )
parse a content-type header .