Expand description
Pure pieces of the client’s HTTP cache: key derivation, Cache-Control and
Retry-After parsing, the storage decision, and the on-disk entry format.
Experimental until 0.9. This module does no I/O and reads no clock; callers
pass times as Unix seconds. libtea-client does the file work
(docs/cache.md).
A cache entry is not a trusted statement. The entry format carries a
length and a SHA-256 of the body so that truncation and accidental
corruption are detected. Anyone who can write the cache directory can write
a consistent entry, so the hash is not authentication. Artifact bytes are
therefore checked against the declared checksums every time they are used,
and the directory is created private (docs/cache.md).
Structs§
- Cache
Control - The directives of
Cache-Controlthis client acts on. - Cache
Entry Meta - Metadata of one stored response.
- Entry
Builder - Builds an entry while the body is still arriving.
Enums§
- Entry
Error - Why an entry was refused.
- NotStored
- Why a response was not stored.
Constants§
- CACHE_
FORMAT_ VERSION - Entry layout version written and read by this crate.
- MAX_
META_ BYTES - Largest metadata block accepted.
- STORED_
HEADERS - Response headers an entry keeps, and nothing else.
Functions§
- cache_
key - The cache key of a request: lowercase hex SHA-256 over the method, the normalized URL, and a digest of the origin and the API key id (never the secret). Requests from different keys, or to different origins, never share an entry.
- decode_
entry - Decode and check an entry.
- encode_
entry - Encode a whole entry in memory.
- is_
cache_ key - Whether
keylooks like a key produced bycache_key. - is_
storable_ header - Whether a header may be written to an entry: allow-listed, and a value of visible ASCII (and tab) no longer than 8 KiB.
- parse_
retry_ after - Seconds to wait according to a
Retry-Aftervalue. - storage_
decision - Decide whether a response may be stored.