def flat_header_val_to_dict(header_val):
    """
    Transform a header string of comma separated parameters into a dict
    """
    val_dict = {}
    val_comps = header_val.rsplit(',')
    if len(val_comps):
        for val_comp in val_comps:
            key, sep, val = val_comp.partition("=")
            if sep != "=":
                return {}
            key = key.strip()
            val = val.strip()
            val = val.strip('"')
            if key in val_dict:
                if isinstance(val_dict[key], list):
                    val_dict[key].append(val)
                else:
                    val_dict[key] = [val_dict[key], val]
            else:
                val_dict[key] = val
    return val_dict