From 292c098cc791bd7976e001191cb8a44c012e86f3 Mon Sep 17 00:00:00 2001 From: yann-dubrana <135650290+yann-dubrana@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:25:05 +0200 Subject: [PATCH] fix headers if cache encoder return custom response --- fastapi_cache/decorator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastapi_cache/decorator.py b/fastapi_cache/decorator.py index 7df09e8..9ab8db3 100644 --- a/fastapi_cache/decorator.py +++ b/fastapi_cache/decorator.py @@ -221,7 +221,8 @@ def cache( return response result = cast(R, coder.decode_as_type(cached, type_=return_type)) - + if isinstance(result, Response): + result.headers.update(response.headers) return result inner.__signature__ = _augment_signature(wrapped_signature, *to_inject) # type: ignore[attr-defined]