litestar icon indicating copy to clipboard operation
litestar copied to clipboard

Enabled caching and RateLimitMiddleware duplicate all `Ratelimt-*` headers in response

Open mikhail-tokarev opened this issue 7 months ago • 0 comments

Description

with litestar.middleware.rate_limit.RateLimitMiddleware added to app middleware and cache=True enabled on route handler you can observe duplicates for all Ratelimit-* response headers like this:

Screenshot 2024-07-12 at 10 26 17

URL to code causing the issue

No response

MCVE

from litestar import Litestar, MediaType, get
from litestar.middleware.rate_limit import RateLimitConfig

rate_limit_config = RateLimitConfig(rate_limit=("minute", 1), exclude=["/schema"])

@get("/", cache=True, media_type=MediaType.TEXT, sync_to_thread=False)
def handler() -> str:
    return "ok"

app = Litestar(route_handlers=[handler], middleware=[rate_limit_config.middleware])

Steps to reproduce

No response

Screenshots

No response

Logs

No response

Litestar Version

2.9.1

Platform

  • [X] Linux
  • [X] Mac
  • [ ] Windows
  • [ ] Other (Please specify in the description above)

[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar

mikhail-tokarev avatar Jul 12 '24 07:07 mikhail-tokarev