I
I
invilso2021-01-12 01:48:01
Lua
invilso, 2021-01-12 01:48:01

How to make post request in lua?

How to make a post request in lua?
It doesn't matter which library you use.
If not difficult, give at least 1 example. For what I find on the Internet does not work (probably my hands are from the wrong place)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
shurshur, 2021-01-12
@invilso

Everything works fine right from the examples googled from the Internet. You need the luasocket library.

local http = require "socket.http"
local ltn12 = require "ltn12"

local reqbody = "{post body}"
local respbody = {} -- for the response body

local result, respcode, respheaders, respstatus = http.request {
    method = "POST",
    url = "https://httpbin.org/post",
    source = ltn12.source.string(reqbody),
    headers = {
        ["content-type"] = "text/plain",
        ["content-length"] = tostring(#reqbody)
    },
    sink = ltn12.sink.table(respbody)
}
-- get body as string by concatenating table filled by sink
respbody = table.concat(respbody)

print (result)
print (respcode)
print (respheaders)
print (respstatus)
print (respbody)

I
Ilya, 2017-04-16
@letehaha

Two queries are better, because if you have a many-to-many relationship, you will have duplicate information about the room.

D
Dimonchik, 2017-04-16
@dimonchik2013

select *
from
    tableA a
        inner join
    tableB b
        on a.common = b.common
        inner join 
    TableC c
        on b.common = c.common

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question