Ocelot
Ocelot copied to clipboard
`"DisableRateLimitHeaders": false` is not showing `X-Rate-Limit` and `Retry-After` headers in response
Expected Behavior / New Feature
configuration file:
{
"Routes" : [ {
"DownstreamPathTemplate": "/users",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "jsonplaceholder.typicode.com",
"Port": 443
}
],
"UpstreamPathTemplate": "/users",
"UpstreamHttpMethod": [ "Get" ],
"RateLimitOptions":
{
"ClientWhitelist": [],
"EnableRateLimiting": true,
"Period": "10s",
"PeriodTimespan": 3,
"Limit": 1
}
}],
"GlobalConfiguration": {
"RateLimitOptions": {
"DisableRateLimitHeaders": true,
"QuotaExceededMessage": "Exceed ",
"HttpStatusCode": 602
}
}
Response headers should contain X-Rate-Limit and Retry-After headers as mentioned in [document](https://ocelot.readthedocs.io/en/latest/features/ratelimiting.html)
Actual Behavior / Motivation for New Feature
It does not contain response headers.
Specifications
- Version:
Hello, as I see the problem is caused by the recent changes in the code. Now httpcontext is used in a different way than before, more: there is a new httpcontext created for each request... I have an idea how to fix it, so I'm going to create a PR soon.
Thanks @jlukawska
+1, X-Rate-Limit and Retry-After headers are not set. Would be handy if this could get fixed since Polly supports automatic retries based on this header.
+1. Just updated my project from netcore3.1 to net5.0 Ocelot v17.0.0 and this breaks rate-limiting on a partner-facing api we host, as it no longer emits the required headers. I've also tried it on net6.0 Ocelot v18.0.0 and same issue.
+ Accepted
...due to the open PR #1307 by @jlukawska