-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
bugfix: read the request body from the temporary file if it was cached. #1863
Conversation
rockspec/apisix-master-0.rockspec
Outdated
@@ -47,7 +47,7 @@ dependencies = { | |||
"luafilesystem = 1.7.0-2", | |||
"lua-tinyyaml = 0.1", | |||
"lua-resty-prometheus = 1.1", | |||
"jsonschema = 0.8", | |||
"jsonschema = 0.9", |
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 not modify this line
t/admin/health-check.t
Outdated
@@ -288,7 +288,7 @@ GET /t | |||
GET /t | |||
--- error_code: 400 | |||
--- response_body | |||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"healthy\" validation failed: property \"http_statuses\" validation failed: expected unique items but items 2 and 1 are equal"} | |||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"healthy\" validation failed: property \"http_statuses\" validation failed: expected unique items but items 1 and 2 are equal"} |
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.
Why did you change this test case?
@moonming in this test case, we found two bugs.
|
one PR only do one think.
Thanks,
Ming Wen
Twitter: _WenMing
YuanSheng Wang <notifications@github.com> 于2020年7月20日周一 下午1:37写道:
…
https://github.com/apache/incubator-apisix/pull/1863/files#diff-00625723b6e737f3cdb18af67165b70fR1899-R1901
@moonming <https://github.com/moonming> in this test case, we found two
bugs.
1. big request body for admin API
2. slower to detect whether the objects in the test array are unique
(jsonschema).
[image: image]
<https://user-images.githubusercontent.com/6814606/87903209-0f5ad800-ca8e-11ea-9c5a-72d5226bc88b.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1863 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJZBK6ZDCBMC7X6NUD4EK3R4PJZJANCNFSM4O54VNRQ>
.
|
apisix/admin/init.lua
Outdated
if req_body then | ||
if #req_body > 1024 * 1024 * 1.5 then |
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.
We need to detect the size (use stat
, for example) before reading it. It doesn't make sense to do the check if we have already read the very BIG file.
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.
agreed.
apisix/admin/init.lua
Outdated
if req_body then | ||
if #req_body > 1024 * 1024 * 1.5 then | ||
core.log.error("maximum request body is 1.5mb, but got ", #req_body) |
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.
IMHO, we can use MiB to indicate the size is 1024 base.
apisix/core/request.lua
Outdated
|
||
|
||
local function get_file(file_name) | ||
local f = io_open(file_name, 'r') |
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.
Better to check the second error returned value before using the f
.
apisix/core/request.lua
Outdated
local function get_file(file_name) | ||
local f = io_open(file_name, 'r') | ||
if f then | ||
local req_body = f:read("*all") |
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.
Ditto
What this PR does / why we need it:
as title, fixed #1784
perf: update the jsonschema to v0.9 .
used hash object to check if there was a duplicated value in the array object,
the current way is 10~100 times than the old way.
Pre-submission checklist: