def parse_header(line):
    """Parse a ``Content-Type`` like header.

    Return the main ``Content-Type`` and a dictionary of options.

    Copied from removed stdlib :mod:`cgi` module. See
    `cherrypy/cherrypy#2014 (comment)
    <https://github.com/cherrypy/cherrypy/issues/2014#issuecomment-1883774891>`_
    for background.
    """
    parts = _parse_param(';' + line)
    key = parts.__next__()
    pdict = {}
    for p in parts:
        i = p.find('=')
        if i >= 0:
            name = p[:i].strip().lower()
            value = p[i + 1 :].strip()
            if len(value) >= 2 and value[0] == value[-1] == '"':
                value = value[1:-1]
                value = value.replace('\\\\', '\\').replace('\\"', '"')
            pdict[name] = value
    return key, pdict
Parse a ``Content-Type`` like header.

    Return the main ``Content-Type`` and a dictionary of options.

    Copied from removed stdlib :mod:`cgi` module. See
    `cherrypy/cherrypy#2014 (comment)
    <https://github.com/cherrypy/cherrypy/issues/2014#issuecomment-1883774891>`_
    for background.
    
cherrypy/_private_api/compat/headers.py