def _conninfo_dsn_parse(dsn: str) -> Optional[Dict[str, str]]:
    """
    >>> r = _conninfo_dsn_parse(" host = 'host' dbname = db\\\\ name requiressl=1 ")
    >>> r == {'dbname': 'db name', 'host': 'host', 'requiressl': '1'}
    True
    >>> _conninfo_dsn_parse('requiressl = 0\\\\') == {'requiressl': '0'}
    True
    >>> _conninfo_dsn_parse("host=a foo = '") is None
    True
    >>> _conninfo_dsn_parse("host=a foo = ") is None
    True
    >>> _conninfo_dsn_parse("1") is None
    True
    """
    ret: Dict[str, str] = {}
    length = len(dsn)
    i = 0
    while i < length:
        if dsn[i].isspace():
            i += 1
            continue

        param_match = PARAMETER_RE.match(dsn[i:])
        if not param_match:
            return

        param = param_match.group(1)
        i += param_match.end()

        if i >= length:
            return

        value, end = read_param_value(dsn[i:])
        if value is None or end is None:
            return
        i += end
        ret[param] = value
    return ret

    >>> r = _conninfo_dsn_parse(" host = 'host' dbname = db\\ name requiressl=1 ")
    >>> r == {'dbname': 'db name', 'host': 'host', 'requiressl': '1'}
    True
    >>> _conninfo_dsn_parse('requiressl = 0\\') == {'requiressl': '0'}
    True
    >>> _conninfo_dsn_parse("host=a foo = '") is None
    True
    >>> _conninfo_dsn_parse("host=a foo = ") is None
    True
    >>> _conninfo_dsn_parse("1") is None
    True
    
patroni/postgresql/config.py