{"id":13583986,"url":"https://github.com/haproxytech/haproxy-lua-http","last_synced_at":"2025-12-30T01:10:14.155Z","repository":{"id":48920723,"uuid":"132448068","full_name":"haproxytech/haproxy-lua-http","owner":"haproxytech","description":"Simple Lua HTTP helper \u0026\u0026 client for use with HAProxy.","archived":false,"fork":false,"pushed_at":"2021-07-05T17:39:20.000Z","size":73,"stargazers_count":56,"open_issues_count":2,"forks_count":23,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-06T00:39:39.541Z","etag":null,"topics":["haproxy","http-client","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haproxytech.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2018-05-07T11:00:23.000Z","updated_at":"2024-08-19T14:33:38.000Z","dependencies_parsed_at":"2022-09-13T19:11:25.003Z","dependency_job_id":null,"html_url":"https://github.com/haproxytech/haproxy-lua-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haproxytech%2Fhaproxy-lua-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haproxytech%2Fhaproxy-lua-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haproxytech%2Fhaproxy-lua-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haproxytech%2Fhaproxy-lua-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haproxytech","download_url":"https://codeload.github.com/haproxytech/haproxy-lua-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557010,"owners_count":20958035,"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":["haproxy","http-client","lua"],"created_at":"2024-08-01T15:03:56.598Z","updated_at":"2025-12-30T01:10:14.092Z","avatar_url":"https://github.com/haproxytech.png","language":"Lua","readme":"Lua HTTP client library for HAProxy\n===================================\n\nThis is a pure Lua HTTP 1.1 library for HAProxy. It should work on any modern\nHAProxy version (1.7+)\n\nThe library is loosely modeled after Python's Requests Library using the same\nattribute names and similar calling conventions for \"HTTP verb\" methods (where\nwe use Lua specific named parameter support)\n\nIn addition to client side, the library also supports server side request\nparsing, where we utilize HAProxy Lua API for all heavy lifting (i.e. HAProxy\nhandles client side connections, parses the headers and gives us access to\nrequest body).\n\nUsage\n-----\n\nAfter downloading this library, you will need to move it into your Lua package\npackage path, to be able to use it from your script. In later HAProxy versions,\nthere is a ``lua-prepend-path`` directive which can make your life easier.\n\nBasic usage for parsing client requests, constructing responses, or sending\ncustom requests to external servers is demonstrated bellow. You can use this in\nyour own Lua actions or services:\n\n.. code-block:: lua\n\n  local http = require('http')\n\n  local function main(applet)\n\n      -- 1) Parse client side request and print received headers\n\n      local req = http.request.parse(applet)\n      for k, v in req:get_headers() do\n          core.Debug(k .. \": \" .. v)\n      end\n\n      -- You can also parse submitted form data\n      local form, err = req:parse_multipart()\n\n      -- 2) Send request to external server (please note there is no DNS\n      --    support for Lua on HAProxy\n\n      local res, err = http.get{url=\"http://1.2.3.4\",\n          headers={host=\"example.net\", [\"x-test\"]={\"a\", \"b\"}}\n      }\n\n      if res then\n          for k, v in res:get_headers() do\n              core.Debug(k .. \": \" .. v)\n          end\n          -- We can access the response body in content attribute\n          core.Debug(res.content)\n      else\n        core.Debug(err)\n      end\n\n\n      -- 3) Send response to client side\n      http.response.create{status_code=200, content=\"Hello World\"}:send(applet)\n\n  end\n\n  core.register_service(\"test\", \"http\", main)\n\nNaturally, you need to add your script to main haproxy configuration::\n\n  global\n    ...\n    lua-load test.lua\n\n  frontend test\n    ...\n    http-request use-service lua.test\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaproxytech%2Fhaproxy-lua-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaproxytech%2Fhaproxy-lua-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaproxytech%2Fhaproxy-lua-http/lists"}