harp.http.utils

hop_by_hop_names(headers)[source]

The header names in this message that belong to its connection rather than to the message.

Connection is why this depends on the message and not only on the fixed set above: it names further fields as connection-specific, so a sender can mark anything it likes. Dropping Connection itself while passing on what it named is the half that looks correct and is not.

Parameters:

headers – any mapping of header names to values, matched case-insensitively.

Return type:

set

parse_cache_control(value)[source]

Parse a Cache-Control header from either a request or response.

This is the main entry point for parsing.

Args:

value: The Cache-Control header value

Returns:

CacheControl object containing all parsed directives

Examples:
>>> # Response example
>>> cc = parse_cache_control("public, max-age=3600, must-revalidate")
>>> cc.public
True
>>> cc.max_age
3600
>>> cc.must_revalidate
True
>>> # Request example
>>> cc = parse_cache_control("max-age=0, no-cache")
>>> cc.max_age
0
>>> cc.no_cache
True
>>> # With field names
>>> cc = parse_cache_control('no-cache="Set-Cookie, Authorization"')
>>> cc.no_cache
['Set-Cookie', 'Authorization']
>>> # Experimental directives
>>> cc = parse_cache_control("immutable, stale-while-revalidate=86400")
>>> cc.immutable
True
>>> cc.stale_while_revalidate
86400
Parameters:

value (str | None)

Return type:

CacheControl

Return a dictionary parsed from a Cookie: header string.

Submodules