Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local curl = require "cURL"
- local function main()
- local e = curl.easy()
- local code, body
- --e:setopt_verbose(true)
- -- Надеюсь, эта функция вызывается ровно один раз для каждого запроса
- e:setopt_writefunction(function(data) body = data end)
- e:setopt_url("https://httpbin.org/get")
- e:perform()
- code = e:getinfo(curl.INFO_RESPONSE_CODE)
- print(code, body)
- e:setopt_forbid_reuse(true)
- e:setopt_url("https://httpbin.org/status/418")
- e:perform()
- code = e:getinfo(curl.INFO_RESPONSE_CODE)
- print(code, body)
- e:close()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment