我正在研究一個Lua腳本,它將由第三方程序託管(某些.exe會調用我的某個函數腳本)。爲了實現我需要的功能(使Web服務休息一下以檢索某些信息)我想使用socket.http.request
。Lua socket.http從示例腳本加載得很好,但不從第三方主機加載
我已經先建立呼叫我想作一個示例腳本:
local io = require("io")
local http = require("socket.http")
local ltn12 = require("ltn12")
local data = "some data")
local response = {}
socket.http.request({
method = "POST",
url = "http://localhost:8080/someServce/rest/commands/someCommand",
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = string.len(data)
},
source = ltn12.source.string(data),
sink = ltn12.sink.table(response)
})
print(table.concat(response))
print("Done")
這工作得很好。我收到了我期望的答覆。 現在,當我嘗試從第三方主機做到這一點,我第一次得到了一個錯誤:
module 'socket.http' not found:
no field package.preload['socket.http']
no file '.\socket\http.lua'
no file 'D:\SomeFolder\lua\socket\http.lua'
no file 'D:\SomeFolder\lua\socket\http\init.lua'
no file 'D:\SomeFolder\socket\http.lua'
no file 'D:\SomeFolder\socket\http\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\http.luac'
no file '.\socket\http.dll'
no file 'D:\SomeFolder\socket\http.dll'
no file 'D:\SomeFolder\loadall.dll'
no file '.\socket.dll'
no file 'D:\SomeFolder\socket.dll'
no file 'D:\SomeFolder\loadall.dll'
我試圖複製從LUA文件夾複製到主機從(d執行文件夾中的文件夾插座: \ SomeFolder)。然後它找到該模塊,但未能加載另一個錯誤:
loop or previous error loading module 'socket.http'
我也嘗試將require語句移到函數之外並使其成爲全局函數。這給了我又一個錯誤:
module 'socket.core' not found:
no field package.preload['socket.core']
no file '.\socket\core.lua'
no file 'D:\SomeFolder\lua\socket\core.lua'
no file 'D:\SomeFolder\lua\socket\core\init.lua'
no file 'D:\SomeFolder\socket\core.lua'
no file 'D:\SomeFolder\socket\core\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\core.luac'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\core.lua'
no file '.\socket\core.dll'
no file 'D:\SomeFolder\socket\core.dll'
no file 'D:\SomeFolder\loadall.dll'
no file '.\socket.dll'
no file 'D:\SomeFolder\socket.dll'
no file 'D:\SomeFolder\loadall.dll'
然後我試圖複製從插座上core.dll到d:\ SomeFolder文件夾,它給了我另一個錯誤:
error loading module 'socket.core' from file '.\socket\core.dll':
%1 is not a valid Win32 application.
現在我被困。我認爲我必須做一些完全錯誤的事情,但我無法找到任何關於如何解決這類問題的適當說明。誰能幫我嗎?
第三方主機運行什麼操作系統? – luastoned
@luastoned:當前所有內容都在Windows上運行。我正在自己的Windows 7系統上進行這項工作。 –