Skip to content

Commit

Permalink
remove header key case conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharat Sinha committed Sep 10, 2024
1 parent 4b37ca7 commit 6e180e7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions fastapi_cache/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,14 @@ def _uncacheable(request: Optional[Request]) -> bool:

def _extract_cache_control_headers(request: Optional[Request]) -> Set[str]:
"""Extracts Cache-Control header
1. Convert all header to lowercase to make it case insensitive
2. Split on comma (,)
3. Strip whitespaces
4. convert to all lower case
1. Split on comma (,)
2. Strip whitespaces
3. convert to all lower case
returns an empty set if header not set
"""
if request is not None:
headers = {header_key.lower(): header_val for header_key, header_val in request.headers.items()}
cache_control_header = headers.get("cache-control", None)
cache_control_header = request.headers.get("cache-control", None)
if cache_control_header:
return {cache_control_val.strip().lower() for cache_control_val in cache_control_header.split(",")}
return set()
Expand Down

0 comments on commit 6e180e7

Please sign in to comment.