Best way to check for http_async?
-
I'm trying to implement the support for http_async in my Virtual Devices plugins. From my tests, Vera's UI seems less busy, but I want to automatically detect if it's installed. Right now I'm using a code like this one:
if pcall(require, "http_async") then else ... end
but I'm not sure it's the best way to do it. Any one? @akbooer? Thanks!
-
Yes, that's about it. Here's an example from openLuup's
client.lua
file:local OKmd5,md5 = pcall (require, "md5") -- for digest authenication (may be missing)
...so then I can write:
if not OKmd5 then return nil, "MD5 module not available for digest authorization" end
which very readable and understandable.
-
The LuaSocket library is a bit flakey on timeouts. It’s also somewhat version-specific.
What, I think, should happen is that the request timeout picks up the current value of the socket library’s global TIMEOUT when the request is made. You could try setting that before he call (and perhaps then reverting to its previous value.)