Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using cURL in lua

Tags:

curl

lua

I am trying to use the curl library in a little lua script.

I know there is a "-k" option to disable the certification verification that curl does by default... but I haven't been able to find how to do it via code.

here's what I have so far:

  local cURL = require("cURL")

    headers = {"Accept: text/*",
               "Accept-Language: en",
               "Accept-Charset: iso-8859-1,*,utf-8",
               "Cache-Control: no-cache"}
    login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"

    c = cURL.easy_init()
    c:setopt_url(login_url)

    c:perform({writefunction=function(str)
                                succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
                             end }) 

Thanks for your time.

like image 204
dot Avatar asked Feb 01 '26 13:02

dot


1 Answers

With new version of Lua-cURL[1] you can write

local cURL = require("cURL")

headers = {
  "Accept: text/*",
  "Accept-Language: en",
  "Accept-Charset: iso-8859-1,*,utf-8",
  "Cache-Control: no-cache"
}

login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"

c = cURL.easy{
  url            = login_url,
  ssl_verifypeer = false,
  ssl_verifyhost = false,
  httpheader     = headers,
  writefunction  = function(str)
    succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
  end
}

c:perform()

1 - https://github.com/Lua-cURL/Lua-cURLv3

like image 138
moteus Avatar answered Feb 04 '26 04:02

moteus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!