37 lines
914 B
Lua
37 lines
914 B
Lua
|
--require = GLOBAL.require
|
||
|
--require("http.request")
|
||
|
local request = require("http")
|
||
|
local json = require("json")
|
||
|
|
||
|
core.register_action("test", { "http-req" }, function(txn)
|
||
|
local info = {}
|
||
|
local headers = {}
|
||
|
|
||
|
local reqbody = txn.sf:req_body()
|
||
|
local reqclientip = txn.f:src()
|
||
|
local reqheaders = txn.http:req_get_headers()
|
||
|
local reqmethod = txn.f:method()
|
||
|
local reqpath = txn.f:path()
|
||
|
|
||
|
info["body"] = reqbody
|
||
|
info["clientip"] = reqclientip
|
||
|
local headers = {}
|
||
|
for k,v in pairs(reqheaders) do
|
||
|
headers[k] = {}
|
||
|
for z,y in pairs(v) do
|
||
|
table.insert(headers[k],y)
|
||
|
end
|
||
|
end
|
||
|
info["headers"] = headers
|
||
|
info["method"] = reqmethod
|
||
|
info["path"] = reqpath
|
||
|
|
||
|
local infojson = json.encode(info)
|
||
|
--local req = request.new_from_uri("https://ipbl.paulbsd.com")
|
||
|
--local headers, stream = req:go()
|
||
|
--local body = assert(stream:get_body_as_string())
|
||
|
|
||
|
txn.Info(txn, infojson)
|
||
|
end
|
||
|
)
|