增加测试cjson大小和请求体大小的测试程序
This commit is contained in:
parent
94dcca1c72
commit
5191044d8a
|
|
@ -1,4 +1,4 @@
|
||||||
worker_processes 1; #nginx worker 数量
|
worker_processes auto; #nginx worker 数量
|
||||||
error_log logs/error.log; #指定错误日志文件路径
|
error_log logs/error.log; #指定错误日志文件路径
|
||||||
|
|
||||||
#worker_rlimit_nofile 65535;
|
#worker_rlimit_nofile 65535;
|
||||||
|
|
@ -8,6 +8,9 @@ events {
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
client_max_body_size 10k; #允许最大100k的请求体
|
||||||
|
client_body_buffer_size 4k; #设置缓冲区大小
|
||||||
|
|
||||||
lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;;';
|
lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;;';
|
||||||
lua_package_cpath '$prefix/src/share/lib/?.so;;';
|
lua_package_cpath '$prefix/src/share/lib/?.so;;';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,7 @@
|
||||||
location /testSQL {
|
location /testSQL {
|
||||||
content_by_lua_file '/home/frankly/work/AuthPlatform/src/test/testPostgres.lua';
|
content_by_lua_file '/home/frankly/work/AuthPlatform/src/test/testPostgres.lua';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /cjson {
|
||||||
|
content_by_lua_file '/home/frankly/work/AuthPlatform/src/test/test.lua';
|
||||||
|
}
|
||||||
|
|
@ -3,3 +3,35 @@
|
||||||
--- Created by admin.
|
--- Created by admin.
|
||||||
--- DateTime: 2025/10/15 09:12
|
--- DateTime: 2025/10/15 09:12
|
||||||
---
|
---
|
||||||
|
|
||||||
|
--读取请求体的数据
|
||||||
|
ngx.req.read_body()
|
||||||
|
|
||||||
|
--获取请求数据
|
||||||
|
local body_data = ngx.req.get_body_data()
|
||||||
|
|
||||||
|
if not body_data then
|
||||||
|
ngx.say("read file error:"..err)
|
||||||
|
return ngx.exit(400)
|
||||||
|
end
|
||||||
|
|
||||||
|
ngx.say(body_data)
|
||||||
|
|
||||||
|
|
||||||
|
--local cjson = require("cjson")
|
||||||
|
--local file_path = "/home/frankly/work/test.dat"
|
||||||
|
--local file_length = 1024 * 1024 * 380
|
||||||
|
--local f, err = io.input(file_path, "r")
|
||||||
|
--if not f then
|
||||||
|
-- ngx.say("read file error:"..err)
|
||||||
|
-- return
|
||||||
|
--end
|
||||||
|
--local content = f:read(file_length) --读取文件内容
|
||||||
|
--f:close() --关闭文件
|
||||||
|
----ngx.say(content)
|
||||||
|
--local res = {
|
||||||
|
-- key = "data",
|
||||||
|
-- value = content
|
||||||
|
--}
|
||||||
|
--ngx.header["Content-Type"] = 'application/json; charset=UTF-8'
|
||||||
|
--ngx.say(cjson.encode(res))
|
||||||
Loading…
Reference in New Issue
Block a user