lua http socket timeout

ripat picture ripat · May 16, 2011 · Viewed 9.1k times · Source

The LuaSocket HTTP module documentation says that a timeout can be set on a HTTP connection:

The following constants can be set to control the default behavior of the HTTP module:

PORT: default port used for connections; PROXY: default proxy used for connections; TIMEOUT: sets the timeout for all I/O operations; USERAGENT: default user agent reported to server. http://w3.impa.br/~diego/software/luasocket/http.htm

How do I set these constants in a lua script?

Answer

ripat picture ripat · May 16, 2011

It was easier than I thought. simply

local mysocket = require("socket.http")
mysocket.TIMEOUT = 5