def header_expand(headers):

    collector = []

    if isinstance(headers, dict):
        headers = headers.items()

    elif isinstance(headers, basestring):
        return headers

    for i, (value, params) in enumerate(headers):

        _params = []

        for (p_k, p_v) in params.items():

            _params.append('%s=%s' % (p_k, p_v))

        collector.append(value)
        collector.append('; ')

        if len(params):

            collector.append('; '.join(_params))

            if not len(headers) == i+1:
                collector.append(', ')


    # Remove trailing separators.
    if collector[-1] in (', ', '; '):
        del collector[-1]

    return ''.join(collector)
compose two maps as functions. a map is assumed to be the identity for keys not present
dataset/ETHPy150Open bububa/pyTOP/pyTOP/packages/requests/utils.py/header_expand--crossover with--dataset/ETHPy150Open Microsoft/ivy/src/ivy/ivy_utils.py/compose_maps