All Projects → Lua-cURL → Lua Curlv3

Lua-cURL / Lua Curlv3

Licence: mit
Lua binding to libcurl

Programming Languages

c
50402 projects - #5 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to Lua Curlv3

flutter curl
Flutter plugin to use libcurl for HTTP calls
Stars: ✭ 42 (-78.68%)
Mutual labels:  curl, libcurl
request-extra
⚡️ Extremely stable HTTP request module built on top of libcurl with retries, timeouts and callback API
Stars: ✭ 14 (-92.89%)
Mutual labels:  curl, libcurl
fortran-curl
Fortran 2008 interface bindings to libcurl
Stars: ✭ 25 (-87.31%)
Mutual labels:  curl, libcurl
Curlsharp
CurlSharp - .Net binding and object-oriented wrapper for libcurl.
Stars: ✭ 153 (-22.34%)
Mutual labels:  curl, libcurl
Curlcpp
An object oriented C++ wrapper for CURL (libcurl)
Stars: ✭ 462 (+134.52%)
Mutual labels:  curl, libcurl
libopenTIDAL
TIDAL API interface written in ANSI C
Stars: ✭ 17 (-91.37%)
Mutual labels:  curl, libcurl
curly.hpp
Simple cURL C++17 wrapper
Stars: ✭ 48 (-75.63%)
Mutual labels:  curl, libcurl
Curl For Win
Reproducible curl (and OpenSSL) binaries for Windows
Stars: ✭ 352 (+78.68%)
Mutual labels:  curl, libcurl
Curl
A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP. libcurl offers a myriad of powerful features
Stars: ✭ 22,875 (+11511.68%)
Mutual labels:  curl, libcurl
Node Libcurl
libcurl bindings for Node.js
Stars: ✭ 447 (+126.9%)
Mutual labels:  curl, libcurl
Gmod Chttp
A HTTP()-compatible wrapper for curl in Garry's Mod.
Stars: ✭ 39 (-80.2%)
Mutual labels:  curl, libcurl
Everything Curl
The book documenting the curl project, the curl tool, libcurl and everything related to this.
Stars: ✭ 885 (+349.24%)
Mutual labels:  curl, libcurl
Katipo
HTTP2 client for Erlang based on libcurl and libevent
Stars: ✭ 90 (-54.31%)
Mutual labels:  curl, libcurl
Php Whois
PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 5.4+ and 7+ compatible
Stars: ✭ 179 (-9.14%)
Mutual labels:  curl
Curl To Csharp
curl to C# converter
Stars: ✭ 153 (-22.34%)
Mutual labels:  curl
Knproxy
Lightweight, PHP-based Web Proxy that can utilize whatever remote connecting ablities your server has to offer. It should work out of the box. No configuration needed. For educational purposes.
Stars: ✭ 148 (-24.87%)
Mutual labels:  curl
Github.vim
Another github v3 api implemented in vim script
Stars: ✭ 187 (-5.08%)
Mutual labels:  curl
Zebra curl
A high performance cURL PHP library for running of multiple requests at once, asynchronously
Stars: ✭ 172 (-12.69%)
Mutual labels:  curl
Httpp
Micro http server and client written in C++
Stars: ✭ 144 (-26.9%)
Mutual labels:  curl
Owasp Mth3l3m3nt Framework
OWASP Mth3l3m3nt Framework is a penetration testing aiding tool and exploitation framework. It fosters a principle of attack the web using the web as well as pentest on the go through its responsive interface.
Stars: ✭ 139 (-29.44%)
Mutual labels:  curl

Lua binding to libcurl

Build Status Build status Coverage Status Licence

Status

This module include three layer

  1. lcurl module provide low level pure C binding to libcurl.
    Almost ready and needs tests. I have no plans to change this API.

  2. cURL module provide compatibility for Lua-cURLv2 API.
    Almost ready and needs tests.

  3. cURL module provide new high level API.
    In fact for now it provide lcurl API directly and needed to redesign.

Documentation

lcurl API
Lua-cURLv2 API
Lua-cURLv3 API

Original Lua-cURLv2 binding has several problems:

  • it can not return error codes but just raise Lua errors (Fixed. use cURL.safe module)
  • it raise Lua error from callback that may result resource leak in libcurl (Fixed.)
  • it does not provide building multipart/formdata explicitly (Fixed.)
  • it has memory leak when send multipart/formdata (Fixed.)
  • it does not save string for curl options that may result crush in libcurl (Fixed.)
  • there no way to get result for operations in multi interface (e.g. if one of easy operation fail you can not get result code/error message) (Fixed. But it does not very handy interface.)
  • you can not use your own callback function to perform operation with multi interface (Could not be fixed without changing API.)
  • you can not pass your context to callback functions (Could not be fixed without changing API.)

Installation

Using LuaRocks:

luarocks install Lua-cURL

Install current master:

luarocks install Lua-cURL --server=https://luarocks.org/dev

List of incompatibility with original Lua-cURLv2

  • objects are tables
  • multi:perform() also returns ("done",code), ("error",error) and ("response",code) records
  • writer callback does not recv string len (just string itself)
  • on Lua > 5.2 errors are objects but not strings

Usage

-- HTTP Get
curl.easy{
    url = 'http://httpbin.org/get',
    httpheader = {
      "X-Test-Header1: Header-Data1",
      "X-Test-Header2: Header-Data2",
    },
    writefunction = io.stderr -- use io.stderr:write()
  }
  :perform()
:close()
-- HTTP Post
curl.easy()
  :setopt_url('http://posttestserver.com/post.php')
  :setopt_writefunction(io.write)
  :setopt_httppost(curl.form() -- Lua-cURL guarantee that form will be alive
    :add_content("test_content", "some data", {
      "MyHeader: SomeValue"
    })
    :add_buffer("test_file", "filename", "text data", "text/plain", {
      "Description: my file description"
    })
    :add_file("test_file2", "BuildLog.htm", "application/octet-stream", {
      "Description: my file description"
    })
  )
  :perform()
:close()
-- FTP Upload
local function get_bin_by(str,n)
  local pos = 1 - n
  return function()
    pos = pos + n
    return (str:sub(pos,pos+n-1))
  end
end

curl.easy()
  :setopt_url("ftp://moteus:[email protected]/test.dat")
  :setopt_upload(true)
  :setopt_readfunction(
    get_bin_by(("0123456789"):rep(4), 9)
  )
  :perform()
:close()
-- Multi FTP Upload

-- We get error E_LOGIN_DENIED for this operation
e1 = curl.easy{url = "ftp://moteus:[email protected]/test1.dat", upload = true}
  :setopt_readfunction(
    function(t) return table.remove(t) end, {"1111", "2222"}
  )

e2 = curl.easy{url = "ftp://moteus:[email protected]/test2.dat", upload = true}
  :setopt_readfunction(get_bin_by(("e"):rep(1000), 5))

m = curl.multi()
m:add_handle(e1)
m:add_handle(e2)

while m:perform() > 0 do m:wait() end

while true do
  h, ok, err = m:info_read()
  if h == 0 then break end

  if h == e1 then 
    assert(ok == nil)
    assert(err:name() == "LOGIN_DENIED")
    assert(err:no() == curl.E_LOGIN_DENIED)
  end

  if h == e2 then 
    assert(ok == true)
  end
end
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].