ietfparse/headers.py
def parse_cache_control(header_value):
    """
    Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.

    Any of the ``Cache-Control`` parameters that do not have directives, such
    as ``public`` or ``no-cache`` will be returned with a value of ``True``
    if they are set in the header.

    :param str header_value: ``Cache-Control`` header value to parse
    :return: the parsed ``Cache-Control`` header values
    :rtype: dict

    .. _Cache-Control: https://tools.ietf.org/html/rfc7234#section-5.2

    """
    directives = {}

    for segment in parse_list(header_value):
        name, sep, value = segment.partition('=')
        if sep != '=':
            directives[name] = None
        elif sep and value:
            value = _dequote(value.strip())
            try:
                directives[name] = int(value)
            except ValueError:
                directives[name] = value
        # NB ``name='' is never valid and is ignored!

    # convert parameterless boolean directives
    for name in _CACHE_CONTROL_BOOL_DIRECTIVES:
        if directives.get(name, '') is None:
            directives[name] = True

    return directives
def parse_cache_control(header_value):
    directives = {}

    for segment in parse_list(header_value):
        name, sep, value = segment.partition('=')
        if sep != '=':
            directives[name] = None
        elif sep and value:
            value = _dequote(value.strip())
            try:
                directives[name] = int(value)
            except ValueError:
                directives[name] = value
        # NB ``name='' is never valid and is ignored!

    # convert parameterless boolean directives
    for name in _CACHE_CONTROL_BOOL_DIRECTIVES:
        if directives.get(name, '') is None:
            directives[name] = True

    return directives
def parse_cache_control ( header_value ) : directives = { } for segment in parse_list ( header_value ) : name , sep , value = segment . partition ( '=' ) if sep != '=' : directives [ name ] = None elif sep and value : value = _dequote ( value . strip ( ) ) try : directives [ name ] = int ( value ) except ValueError : directives [ name ] = value # NB ``name='' is never valid and is ignored! # convert parameterless boolean directives for name in _CACHE_CONTROL_BOOL_DIRECTIVES : if directives . get ( name , '' ) is None : directives [ name ] = True return directives
Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.

    Any of the ``Cache-Control`` parameters that do not have directives, such
    as ``public`` or ``no-cache`` will be returned with a value of ``True``
    if they are set in the header.

    :param str header_value: ``Cache-Control`` header value to parse
    :return: the parsed ``Cache-Control`` header values
    :rtype: dict

    .. _Cache-Control: https://tools.ietf.org/html/rfc7234#section-5.2
Parse a Cache - Control _ header returning a dictionary of key - value pairs .