{"id":14990031,"url":"https://github.com/moteus/lua-lluv-curl","last_synced_at":"2025-04-12T02:03:37.473Z","repository":{"id":147045390,"uuid":"81463997","full_name":"moteus/lua-lluv-curl","owner":"moteus","description":"Make asyncronus requests using libuv and libcurl","archived":false,"fork":false,"pushed_at":"2019-07-02T07:51:46.000Z","size":28,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T02:03:31.145Z","etag":null,"topics":["async","curl","libcurl","libuv","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moteus.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-09T15:23:28.000Z","updated_at":"2023-04-12T07:17:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e5e8aae-82f3-4404-985a-b1a17a2713bd","html_url":"https://github.com/moteus/lua-lluv-curl","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"8a02dd8542383419060151f4de0a2e35eaf2ecbe"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-lluv-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-lluv-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-lluv-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-lluv-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moteus","download_url":"https://codeload.github.com/moteus/lua-lluv-curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505863,"owners_count":21115354,"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":["async","curl","libcurl","libuv","lua"],"created_at":"2024-09-24T14:19:21.634Z","updated_at":"2025-04-12T02:03:37.442Z","avatar_url":"https://github.com/moteus.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lua-lluv-curl\nMake asyncronus requests using libuv and libcurl\n\nThis module provide async version of curl multi class.\nAlso module implement async request queue class which allows\ncontrol number of parallel requests.\n\n### Examples\n\n#### Basic asyncronus request using easy handle\n```Lua\nlocal uv   = require \"lluv\"\nlocal curl = require \"lluv.curl\"\n\nlocal easy = curl.easy{\n  url = \"http://example.com\";\n  writefunction = io.write;\n}\n\nlocal multi = curl.multi()\n\nmulti:add_handle(easy, function(easy, err)\n  print(\"Done:\", err or easy:getinfo_response_code())\nend)\n\nuv.run()\n```\n\n#### Implementation of [uvwget](http://nikhilm.github.io/uvbook/utilities.html#external-i-o-with-polling) example from [An Introduction to libuv](http://nikhilm.github.io/uvbook/index.html) book\n```Lua\nlocal curl = require \"lluv.curl\"\n\n-- Create request queue object\nlocal queue = curl.queue{\n  -- Allow up to 10 parallel requests\n  concurent = 10;\n  -- Default options for easy handles\n  defaults = { -- this is valuses used by defualt\n    fresh_connect = true;\n    forbid_reuse  = true;\n  };\n}\n\nfor i, url in ipairs(arg) do\n  local path, file = tostring(i) .. '.download'\n  -- this function actually put reques in queue\n  -- and returns special `request` object.\n  -- Also it is possible pass any `cURL` options.\n  queue:perform(url, {followlocation = true}, function(request) request\n    -- Here we can configure created request object before it will be used\n\n    -- calls after configuration done but before actually start perform\n    :on('start', function(_, _, easy)\n      file = assert(io.open(path, 'wb+'))\n      easy:setopt_writefunction(file)\n    end)\n    -- calls in any case when task is finish\n    :on('close', function()\n      if file then file:close() end\n    end)\n     -- Some error (e.g. SSL fail or user interupted)\n    :on('error', function(_, _, err)\n      io.stderr:write(url ..  ' - FAIL: ' .. tostring(err) .. '\\n')\n    end)\n    -- This means that request done without any error\n    :on('done', function(_, _, easy)\n      local code = easy:getinfo_response_code()\n      io.stdout:write(url ..  ' - DONE: ' .. tostring(code) .. '; Path: ' ..path .. '\\n')\n    end)\n  end)\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-lluv-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoteus%2Flua-lluv-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-lluv-curl/lists"}