U
U
un_def2014-10-11 13:52:51
Lua
un_def, 2014-10-11 13:52:51

LuaSocket: how to make a non-blocking http request?

There is a script that performs some actions and, if successful, sends it to several http post-request servers:

urls = {'http://test1.dev', 'http://test2.dev'}
http = require('socket.http')
while true do
    result = do_something()
    if result then
        for _, url in ipairs(urls) do
            http.request(url, 'data=' .. result)
        end
    end
end

How to make the request (http.request) execute "in the background", i.e. did not suspend the main thread? In this case, the success of the request and the response of the servers does not matter - i.e. nothing from the request returned by the function is of interest, as well as the very fact of completion of its execution.
I would like to solve the problem without additional third-party modules.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2014-10-12
@daapp

if you want without additional steps - then the easiest way is to run wget or curl in the background with the correct keys.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question