main.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. -- LuaTools需要PROJECT和VERSION这两个信息
  2. PROJECT = "httpdemo"
  3. VERSION = "1.0.0"
  4. -- sys库是标配
  5. _G.sys = require("sys")
  6. -- 暂不支持https请求!!!!!!
  7. sys.taskInit(function()
  8. while 1 do
  9. if socket.isReady() then
  10. sys.wait(2000)
  11. --http.get("http://www.baidu.com/content-search.xml", nil, function(code,headers,data)
  12. -- log.info("http", code, data)
  13. -- sys.publish("HTTP_OK")
  14. --end)
  15. -- sys.waitUntil("HTTP_OK", 15000)
  16. -- 返回当前毫秒数
  17. --http.get("http://site0.cn/api/httptest/simple/time", {}, function(code,headers,data)
  18. -- log.info("http", code, data)
  19. -- sys.publish("HTTP_OK")
  20. --end)
  21. -- sys.waitUntil("HTTP_OK", 15000)
  22. -- 返回当前毫秒数
  23. http.post("http://site0.cn/api/httptest/simple/date", {body=string.rep("1234567890", 100)}, function(code,headers,data)
  24. log.info("http", code, data)
  25. sys.publish("HTTP_OK")
  26. end)
  27. sys.waitUntil("HTTP_OK", 15000)
  28. sys.wait(60000)
  29. else
  30. sys.wait(3000)
  31. end
  32. end
  33. end)
  34. -- 用户代码已结束---------------------------------------------
  35. -- 结尾总是这一句
  36. sys.run()
  37. -- sys.run()之后后面不要加任何语句!!!!!