TSG-11849 tfe增加从环境变量中读入处理机ip
TSG-11742 IP Libraries统一使用.分隔地理层级 TSG-10722 日志中开始时间从解析层获取
This commit is contained in:
73
plugin/business/tsg-http/test/test_data/http_session.lua
Normal file
73
plugin/business/tsg-http/test/test_data/http_session.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
local ctx=tfe.context
|
||||
|
||||
function Sleep2(n)
|
||||
local t0 = os.clock()
|
||||
while os.clock() - t0 <= n do end
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_stage_test")
|
||||
then
|
||||
Sleep2(1000)
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_req_header")
|
||||
then
|
||||
local req_headers_tab = tfe.req.get_headers()
|
||||
for k, v in pairs(req_headers_tab) do
|
||||
print(k,v)
|
||||
if k == "User-Agent" then
|
||||
tfe.req.set_header("user-agent", "curl-v1.1")
|
||||
end
|
||||
if k == "Pragma" then
|
||||
tfe.req.set_header("pragma", "nil")
|
||||
end
|
||||
end
|
||||
--tfe.exit(0)
|
||||
tfe.req.set_header("x-tg-construct-by", "tfe")
|
||||
local method = tfe.req.get_method()
|
||||
print(method)
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_req_uri")
|
||||
then
|
||||
local req_uri=tfe.req.get_uri()
|
||||
if req_uri then
|
||||
tfe.req.set_uri("team")
|
||||
end
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_resp_header")
|
||||
then
|
||||
local resp_headers_tab = tfe.resp.get_headers()
|
||||
for k, v in pairs(resp_headers_tab) do
|
||||
print(k,v)
|
||||
if k == "Content-Type" then
|
||||
tfe.resp.set_header("Content-Type", "utf8")
|
||||
end
|
||||
if k == "Expires" then
|
||||
tfe.resp.set_header("Expires", "nil")
|
||||
end
|
||||
end
|
||||
local status_code = tfe.resp.get_status_code()
|
||||
print(status_code)
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_req_body")
|
||||
then
|
||||
local req_body = tfe.req.get_body_data()
|
||||
if req_body then
|
||||
tfe.req.set_body_data(req_body, " set req body")
|
||||
end
|
||||
len=#req_body
|
||||
return len
|
||||
end
|
||||
|
||||
if(tfe.get_current_stage() == "http_resp_body")
|
||||
then
|
||||
local resp_body = tfe.resp.get_body_data()
|
||||
if resp_body then
|
||||
tfe.resp.set_body_data(resp_body, " set resp body")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user