INNER CODE UNIT · Python

split_http_header

braedon/prometheus-es-exporter · prometheus_es_exporter/__init__.py:370

def split_http_header(header_string):
    """Splits a colon-separated string into header and value"""
    parts = tuple(part.strip() for part in header_string.split(":", 1))
    if len(parts) != 2 or any(part == '' for part in parts):
        msg = "Invalid header '{}'. Use colon to separate name and value".format(header_string)
        raise click.BadParameter(msg)
    return parts


def http_headers_parser(ctx, param, headers):
    """Turn header list into a dict {header: value, ...}"""
    if headers is None:
        return None

    return dict(split_http_header(header_string) for header_string in headers)


def configparser_enum_conv(enum):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…