pgjones / quart-rate-limiter

Quart-Rate-Limiter is an extension for Quart to allow for rate limits to be defined and enforced on a per route basis.
MIT License
23 stars 6 forks source link

Rate limit response seems to override Content-Type header #5

Closed VeryEvilPanda closed 1 year ago

VeryEvilPanda commented 1 year ago

All rate limit exceeded responses seem to have the wrong Content-Type header and appear in the browser as plain text.

In the RateLimitExceeded class, get_headers() returns just the Retry-After header. I don't know the exact way any of the code works, but I assume this overrides the Content-Type header, which is returned in a different get_headers() in the werkzeug HTTPException class.

I was able to fix this for myself by changing the line from return {"Retry-After": str(self.retry_after)} to return {"Retry-After": str(self.retry_after), "Content-Type": "text/html; charset=utf-8"}

I don't know how this should be fixed, but I thought I'd leave this issue to highlight it.

pgjones commented 1 year ago

Thanks, fixed in a9628a1995cfb73fcc4e35dcc44ff197da150331