{"id":14989950,"url":"https://github.com/lua-curl/lua-curlv3","last_synced_at":"2025-04-06T07:13:08.346Z","repository":{"id":20039698,"uuid":"23307884","full_name":"Lua-cURL/Lua-cURLv3","owner":"Lua-cURL","description":"Lua binding to libcurl","archived":false,"fork":false,"pushed_at":"2023-07-03T06:20:14.000Z","size":609,"stargazers_count":286,"open_issues_count":17,"forks_count":65,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-06T07:13:01.940Z","etag":null,"topics":["curl","libcurl","lua","lua-bindings"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"shadowsocks/shadowsocks-gui","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lua-cURL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-08-25T09:00:15.000Z","updated_at":"2025-03-31T05:37:30.000Z","dependencies_parsed_at":"2024-01-08T20:19:18.396Z","dependency_job_id":null,"html_url":"https://github.com/Lua-cURL/Lua-cURLv3","commit_stats":{"total_commits":397,"total_committers":14,"mean_commits":"28.357142857142858","dds":"0.47858942065491183","last_synced_commit":"9f8b6dba8b5ef1b26309a571ae75cda4034279e5"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lua-cURL%2FLua-cURLv3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lua-cURL%2FLua-cURLv3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lua-cURL%2FLua-cURLv3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lua-cURL%2FLua-cURLv3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lua-cURL","download_url":"https://codeload.github.com/Lua-cURL/Lua-cURLv3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445671,"owners_count":20939958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","libcurl","lua","lua-bindings"],"created_at":"2024-09-24T14:19:13.048Z","updated_at":"2025-04-06T07:13:08.323Z","avatar_url":"https://github.com/Lua-cURL.png","language":"C","readme":"# Lua binding to [libcurl](http://curl.haxx.se/libcurl)\n[![Build Status](https://travis-ci.org/Lua-cURL/Lua-cURLv3.svg?branch=master)](https://travis-ci.org/Lua-cURL/Lua-cURLv3)\n[![Build status](https://ci.appveyor.com/api/projects/status/oxiuv2u04ob391k0?svg=true)](https://ci.appveyor.com/project/moteus/lua-curlv3)\n[![Coverage Status](https://coveralls.io/repos/Lua-cURL/Lua-cURLv3/badge.png?branch=master)](https://coveralls.io/r/Lua-cURL/Lua-cURLv3?branch=master)\n[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)\n\n## Status\n\nThis module include three layer\n\n1. `lcurl` module provide low level pure C binding to libcurl.\u003cbr/\u003e\nAlmost ready and needs tests. I have no plans to change this API.\n\n2. `cURL` module provide compatibility for Lua-cURLv2 API.\u003cbr/\u003e\nAlmost ready and needs tests.\n\n3. `cURL` module provide new high level API.\u003cbr/\u003e\nIn fact for now it provide `lcurl` API directly and needed to redesign.\u003cbr/\u003e\n\n\n## Documentation\n[lcurl API](http://lua-curl.github.io/lcurl/modules/lcurl.html)\u003cbr/\u003e\n[Lua-cURLv2 API](http://lua-curl.github.io)\u003cbr/\u003e\n[Lua-cURLv3 API](http://lua-curl.github.io/lcurl/modules/cURL.html)\n\n## \n\nOriginal Lua-cURLv2 binding has several problems:\n\n* it can not return error codes but just raise Lua errors (Fixed. use `cURL.safe` module)\n* it raise Lua error from callback that may result resource leak in libcurl (Fixed.)\n* it does not provide building multipart/formdata explicitly (Fixed.)\n* it has memory leak when send multipart/formdata (Fixed.)\n* it does not save string for curl options that may result crush in libcurl (Fixed.)\n* 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.)\n* you can not use your own callback function to perform operation with multi interface (Could not be fixed without changing API.)\n* you can not pass your context to callback functions (Could not be fixed without changing API.)\n\n## Installation\n\nUsing LuaRocks:\n```\nluarocks install Lua-cURL\n```\n\nInstall current master:\n```\nluarocks install Lua-cURL --server=https://luarocks.org/dev\n```\n\n## List of incompatibility with original [Lua-cURLv2](https://github.com/Lua-cURL/Lua-cURLv2)\n\n* objects are tables\n* multi:perform() also returns (\"done\",code), (\"error\",error) and (\"response\",code) records\n* writer callback does not recv string len (just string itself)\n* on Lua \u003e 5.2 errors are objects but not strings\n\n## Usage\n\n```Lua\n-- HTTP Get\ncurl.easy{\n    url = 'http://httpbin.org/get',\n    httpheader = {\n      \"X-Test-Header1: Header-Data1\",\n      \"X-Test-Header2: Header-Data2\",\n    },\n    writefunction = io.stderr -- use io.stderr:write()\n  }\n  :perform()\n:close()\n```\n\n```Lua\n-- HTTP Post\ncurl.easy()\n  :setopt_url('http://posttestserver.com/post.php')\n  :setopt_writefunction(io.write)\n  :setopt_httppost(curl.form() -- Lua-cURL guarantee that form will be alive\n    :add_content(\"test_content\", \"some data\", {\n      \"MyHeader: SomeValue\"\n    })\n    :add_buffer(\"test_file\", \"filename\", \"text data\", \"text/plain\", {\n      \"Description: my file description\"\n    })\n    :add_file(\"test_file2\", \"BuildLog.htm\", \"application/octet-stream\", {\n      \"Description: my file description\"\n    })\n  )\n  :perform()\n:close()\n```\n\n```Lua\n-- FTP Upload\nlocal function get_bin_by(str,n)\n  local pos = 1 - n\n  return function()\n    pos = pos + n\n    return (str:sub(pos,pos+n-1))\n  end\nend\n\ncurl.easy()\n  :setopt_url(\"ftp://moteus:123456@127.0.0.1/test.dat\")\n  :setopt_upload(true)\n  :setopt_readfunction(\n    get_bin_by((\"0123456789\"):rep(4), 9)\n  )\n  :perform()\n:close()\n```\n\n```Lua\n-- Multi FTP Upload\n\n-- We get error E_LOGIN_DENIED for this operation\ne1 = curl.easy{url = \"ftp://moteus:999999@127.0.0.1/test1.dat\", upload = true}\n  :setopt_readfunction(\n    function(t) return table.remove(t) end, {\"1111\", \"2222\"}\n  )\n\ne2 = curl.easy{url = \"ftp://moteus:123456@127.0.0.1/test2.dat\", upload = true}\n  :setopt_readfunction(get_bin_by((\"e\"):rep(1000), 5))\n\nm = curl.multi()\nm:add_handle(e1)\nm:add_handle(e2)\n\nwhile m:perform() \u003e 0 do m:wait() end\n\nwhile true do\n  h, ok, err = m:info_read()\n  if h == 0 then break end\n\n  if h == e1 then \n    assert(ok == nil)\n    assert(err:name() == \"LOGIN_DENIED\")\n    assert(err:no() == curl.E_LOGIN_DENIED)\n  end\n\n  if h == e2 then \n    assert(ok == true)\n  end\nend\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flua-curl%2Flua-curlv3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flua-curl%2Flua-curlv3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flua-curl%2Flua-curlv3/lists"}