-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(plugin) fixes a wrong constant for the request size limit plugin #1416
Conversation
|
||
local RequestSizeLimitingHandler = BasePlugin:extend() | ||
|
||
RequestSizeLimitingHandler.PRIORITY = 950 | ||
|
||
local function check_size(length, allowed_size, headers) | ||
local allowed_bytes_size = allowed_size * 100000 | ||
local allowed_bytes_size = allowed_size * 1000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it much more convenient and requiring less cognitive load (as well as much less error prone) to declare constants representing size (including MBs) like so:
local CONST_NAME = X * 10^6 -- here X being 1
Then use CONST_NAME
in the module's function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, including a linter fix to make ci run
local stringy = require "stringy" | ||
local strip = require("pl.stringx").strip | ||
|
||
local MEGABYTE = 10^6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 2^20
btw
d8b1619
to
c6545d2
Compare
Summary
constant for mb was 100.000 instead of 1.000.000 causing request to be rejected falsy.
Full changelog
Issues resolved
Fixes #1415