package.path = package.path..";F:\\HOME\\Tools\\luaforwindows-master\\files\\?.lua"
package.cpath = package.cpath..";F:\\HOME\\Tools\\luaforwindows-master\\files\\clibs\\?.dll"
require('luacom')
http = luacom.CreateObject('MSXML2.ServerXMLHTTP')
-- response page (like the follwoing html)
--[[
Test Page
]]
local url = "http://localhost/phpbook2/test.php"
local param1 = "param1"
local param2 = "param2"
local savepath = "result.html"
local dat = "param1="..param1.."¶m2="..param2
-- send post info
http:Open("POST",url,false)
http:SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
http:Send(dat)
http:WaitForResponse(30)
print('Status: '..http.Status)
print('----------------------------------------------------------------')
headers = http:GetAllResponseHeaders()
data = http.Responsetext
print('Data Size = '..#data)
print('----------------------------------------------------------------')
print(headers)
print(data)
-- write response to local file
data = http.responseBody
f = io.open(savepath, "w")
f:write(data)
f:close()