Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy: rate limit headers does not send invalid value. #1209

Merged
merged 1 commit into from
Jul 3, 2020

Conversation

eloycoto
Copy link
Contributor

When the backend does not reply with limit headers, APIcast should send
no limit headers at all. This change make sure that the value is not
send at all.

Also, make sure that the value of limit and reset is always positive or
0.

THREESCALE-3795

Signed-off-by: Eloy Coto [email protected]

@eloycoto eloycoto requested a review from a team as a code owner June 30, 2020 13:01
@@ -55,9 +55,22 @@ local function decrement(self, usage)
return self.cache:decrement_usage_metric(usage)
end

-- return 0 if the number is negative
local function positive_number(number)
if tonumber(number) <= 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return math.max(tonumber(number), 0)

?

local function add_headers(info)
ngx.header[limit_header] = info.limit
ngx.header[remaining_header] = info.remaining
ngx.header["eloy"] = "test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, my head :-(

When the backend does not reply with limit headers, APIcast should send
no limit headers at all. This change make sure that the value is not
send at all.

Also, make sure that the value of limit and reset is always positive or
0.

THREESCALE-3795

Signed-off-by: Eloy Coto <[email protected]>
@eloycoto eloycoto merged commit 29f46eb into 3scale:master Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants