INNER CODE UNIT · Python

_merge_headers

redis/fastapi-redis-sdk · src/redis_fastapi/cache.py:348

def _merge_headers(
    base: list[tuple[bytes, bytes]],
    overrides: list[tuple[bytes, bytes]],
) -> list[tuple[bytes, bytes]]:
    """Return *base* with every field named in *overrides* replaced, not joined.

    The fields this middleware sets are single-valued.  RFC 9110 section 8.8.3
    defines ``ETag = entity-tag`` - one tag, not a list - so appending ours
    beside a validator the endpoint already set would emit a field no client
    can parse, and a conditional request echoing it would never match.
    ``Cache-Control`` appended the same way yields two ``max-age`` directives.

    Args:
        base: Raw ASGI headers as the endpoint produced them.
        overrides: Headers this middleware owns; each replaces every earlier
            occurrence of the same name.

    Returns:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…