effil headers

leekyrave

Известный
Автор темы
418
226
Версия MoonLoader
.026-beta
Приветствую, использую библиотеку effil для запросов и мне нужно указать заголовки.
Получаю такой прикол и аргументы не указываются.
0X5pxyp.png

aSczSrM.png

Lua:
    local token = md5.sumhexa(крутойтокен)
    local args = {}
    args.data = {login = login, pass = md5.sumhexa(password), ip = ip, port = port, serial = serial}
    args.headers = {['Content-Type'] = 'application/json', ['token'] = token}
    asyncHttpRequest('POST', 'http://api.mint-plantation.ru/auth.php', args, function(response) response = response end, nil)
 
Решение
Решил проблему тем, что использовал копас + реквесты и подредачил функцию Фипа.
Lua:
function httpRequest(method, request, headers, args, handler) -- lua-requests
    -- start polling task
    if not copas.running then
        copas.running = true
        lua_thread.create(function()
            wait(0)
            while not copas.finished() do
                local ok, err = copas.step(0)
                if ok == nil then error(err) end
                wait(0)
            end
            copas.running = false
        end)
    end
    -- do request
    if handler then
        return copas.addthread(function(m, r, hh, a, h)
            copas.setErrorHandler(function(err) h(nil, err) end)
            h(requests.request(m, r, hh, a))...

leekyrave

Известный
Автор темы
418
226
Решил проблему тем, что использовал копас + реквесты и подредачил функцию Фипа.
Lua:
function httpRequest(method, request, headers, args, handler) -- lua-requests
    -- start polling task
    if not copas.running then
        copas.running = true
        lua_thread.create(function()
            wait(0)
            while not copas.finished() do
                local ok, err = copas.step(0)
                if ok == nil then error(err) end
                wait(0)
            end
            copas.running = false
        end)
    end
    -- do request
    if handler then
        return copas.addthread(function(m, r, hh, a, h)
            copas.setErrorHandler(function(err) h(nil, err) end)
            h(requests.request(m, r, hh, a))
        end, method, request, headers, args, handler)
    else
        local results
        local thread = copas.addthread(function(m, r, hh, a)
            copas.setErrorHandler(function(err) results = {nil, err} end)
            results = table.pack(requests.request(m, r, hh, a))
        end, method, request, headers, args)
        while coroutine.status(thread) ~= 'dead' do wait(0) end
        return table.unpack(results)
    end
end

Пример использования:
Lua:
    data = {login = login, pass = passwd}
    headers = {['Content-Type'] = 'application/json'}
    local response, err = httpRequest('POST',{'http://api.mint-plantation.ru/auth.php',headers = headers, data = data})
    local response = response.json()