增加测试cjson大小和请求体大小的测试程序

This commit is contained in:
wanglei 2025-10-17 10:16:13 +08:00
parent 94dcca1c72
commit 5191044d8a
3 changed files with 41 additions and 2 deletions

View File

@ -1,4 +1,4 @@
worker_processes 1; #nginx worker 数量
worker_processes auto; #nginx worker 数量
error_log logs/error.log; #指定错误日志文件路径
#worker_rlimit_nofile 65535;
@ -8,6 +8,9 @@ events {
}
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_cpath '$prefix/src/share/lib/?.so;;';

View File

@ -1,4 +1,8 @@
#测试接口文件
location /testSQL {
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';
}

View File

@ -2,4 +2,36 @@
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by admin.
--- 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))