Guest User

Untitled

a guest
Oct 5th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local curl = require "cURL"
  2.  
  3. local function main()
  4.  
  5.   local e = curl.easy()
  6.   local code, body
  7.  
  8.   --e:setopt_verbose(true)
  9.  
  10.   -- Надеюсь, эта функция вызывается ровно один раз для каждого запроса
  11.   e:setopt_writefunction(function(data) body = data end)
  12.  
  13.   e:setopt_url("https://httpbin.org/get")
  14.   e:perform()
  15.   code = e:getinfo(curl.INFO_RESPONSE_CODE)
  16.  
  17.   print(code, body)
  18.  
  19.   e:setopt_forbid_reuse(true)
  20.  
  21.   e:setopt_url("https://httpbin.org/status/418")
  22.   e:perform()
  23.   code = e:getinfo(curl.INFO_RESPONSE_CODE)
  24.  
  25.   print(code, body)
  26.  
  27.   e:close()
  28. end
  29.  
  30. main()
Advertisement
Add Comment
Please, Sign In to add comment