【发布时间】:2013-02-18 17:07:07
【问题描述】:
如何编写脚本以在 Lua 中从 Apache Tomcat 服务器检索当前日期和时间。
【问题讨论】:
如何编写脚本以在 Lua 中从 Apache Tomcat 服务器检索当前日期和时间。
【问题讨论】:
您只需要LuaSocket 就可以连接到您的服务器。它不必是 Tomcat 服务器。尝试运行此代码:
local http = require "socket.http" -- import the socket.http module
local body, httpcode, headers = http.request("http://www.google.com")
local date = headers.date -- LuaSocket makes all header names lowercase
print(date) --> "Mon, 18 Feb 2013 09:03:13 GMT" in my case
【讨论】: