Returns type, subtype, parameter tuple from an http media_type.
    Can be applied to the 'Accept' or 'Content-Type' http header fields.

def parse_media_type(media_type):
    '''Returns type, subtype, parameter tuple from an http media_type.
    Can be applied to the 'Accept' or 'Content-Type' http header fields.
    '''
    media_type, sep, parameter = str(media_type).partition(';')
    media_type, sep, subtype = media_type.partition('/')
    return tuple(x.strip() or None for x in (media_type, subtype, parameter))