def _getContentType(msg):
    """
    Return a two-tuple of the main and subtype of the given message.
    """
    attrs = None
    mm = msg.getHeaders(False, 'content-type').get('content-type', '')
    mm = ''.join(mm.splitlines())
    if mm:
        mimetype = mm.split(';')
        type = mimetype[0].split('/', 1)
        if len(type) == 1:
            major = type[0]
            minor = None
        else:
            # length must be 2, because of split('/', 1)
            major, minor = type
        attrs = dict(x.strip().lower().split('=', 1) for x in mimetype[1:])
    else:
        major = minor = None
    return major, minor, attrs

    Return a two-tuple of the main and subtype of the given message.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/imap4.py