{"id":13636183,"url":"https://github.com/antonheryanto/lua-resty-post","last_synced_at":"2026-01-16T07:48:50.570Z","repository":{"id":35839381,"uuid":"40122784","full_name":"antonheryanto/lua-resty-post","owner":"antonheryanto","description":"HTTP post utility for openresty","archived":false,"fork":false,"pushed_at":"2021-06-24T10:38:19.000Z","size":21,"stargazers_count":34,"open_issues_count":2,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-02-13T00:46:38.056Z","etag":null,"topics":["lua","luajit","nginx","openresty"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonheryanto.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-03T12:11:04.000Z","updated_at":"2024-02-13T00:46:38.057Z","dependencies_parsed_at":"2022-07-09T09:46:15.124Z","dependency_job_id":null,"html_url":"https://github.com/antonheryanto/lua-resty-post","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/antonheryanto%2Flua-resty-post","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonheryanto%2Flua-resty-post/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonheryanto%2Flua-resty-post/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonheryanto%2Flua-resty-post/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonheryanto","download_url":"https://codeload.github.com/antonheryanto/lua-resty-post/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223790562,"owners_count":17203355,"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":["lua","luajit","nginx","openresty"],"created_at":"2024-08-02T00:00:58.226Z","updated_at":"2026-01-16T07:48:50.519Z","avatar_url":"https://github.com/antonheryanto.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"lua-resty-post\n==============\n\nOpenresty utility for HTTP post\n\nTable of Contents\n=================\n* [Status](#status)\n* [Description](#description)\n* [Installation](#installation)\n* [How to use](#how-to-use)\n* [Copyright and License](#copyright-and-license)\n* [See Also](#see-also)\n\nStatus\n======\n\nThis library beta tested and used in production.\n\nDescription\n===========\n\nThis library processed HTTP using [lua-resty-upload](https://github.com/openresty/lua-resty-upload) which very fast and low memory used, it handles multiple type of HTTP POST and converted into lua table:\n* application/x-www-form-urlencoded\n* application/json\n* multipart/form-data\n  * [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n  * [File Upload](#file-upload)\n  * [Array Input](#array-input)\n\n[Back to TOC](#table-of-contents)\n\nInstallation\n============\n\n* Download or clone this repo\n* copy or link to openresty/lualib/resty/ or to any your lua_package_path\n\n[Back to TOC](#table-of-contents)\n\nHow to use\n==========\n\n```lua\nlocal resty_post = require 'resty.post'\nlocal post = resty_post:new()\nlocal m = post:read()\n-- return table with all form value and file\n```\n\n[Back to TOC](#table-of-contents)\n\nFile Upload\n===========\n\n* Support multiple file upload\n* Files info are stored in files property using field name as key\n```lua\n { \n  files = {\n   file1 = { -- input name\n    name = \"a.txt\",\n    type = \"text/plain\",\n    size = 10240,\n    tmp_name = 1454551131.5459\n   },\n   file2 = {\n    name = \"b.png\",\n    type = \"image/png\",\n    size = 20480,\n    tmp_name = 1454553275.6401\n   }\n }\n```\n\n* Define path for files upload or default to logs directory (follow ngx.config.prefix)\n* Default file will be saved to tmp name (require moving action to destination)\n``` lua\nlocal resty_post = require \"resty.post\"\nlocal post = resty_post:new({\n path = \"/my/path\",           -- path upload file will be saved\n chunk_size = 10240,          -- default 8192\n no_tmp = true,               -- if set original name will uses or generate random name\n name = function(name, field) -- overide name with user defined function\n  return name..\"_\"..field \n end\n})\npost:read()\n```\n\n\nArray Input\n===========\n\nSupport multiple input of similar name\n--------------------------------------\nIt is useful for thing like HTML input checkboxes or select in multiple mode\n```html\n\u003cinput type=\"checkbox\" name=\"check_multi\" value=\"1\"\u003e\n\u003cinput type=\"checkbox\" name=\"check_multi\" value=\"2\"\u003e\n\u003cselect name=\"select_multi\" multiple\u003e\n \u003coption value=\"\"\u003ePlease select\u003c/option\u003e\n \u003coption value=\"1\"\u003eOne\u003c/option\u003e\n \u003coption value=\"2\"\u003eTwo\u003c/option\u003e\n\u003c/select\u003e\n```\nconverted into\n``` lua\n{\n check_multi = { 1, 2 },\n select_multi = { 1, 2 } \n}\n```\nWhen checked one similar with [ngx.req.get_post_args](https://github.com/openresty/lua-nginx-module#ngxreqget_post_args)\n``` lua\n{\n check_multi = 2,\n select_multi = 1\n}\n```\n\n\nSupport array input with name\n--------------------------------------\nThis is like supporting input which mimic class and property, which can be uses to handle dynamic input\nsupport PHP style (dynamic language) and ASP.NET MVC binding style (static language which uses class)\n```html\n\u003cdiv class=\"name-index\"\u003e\n \u003cinput name=\"name[1]\" value=\"Foo\"\u003e\n \u003cinput name=\"name[0]\" value=\"Bar\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"user-single\"\u003e\n \u003cinput name=\"user.title\" value=\"Mr.\"\u003e\n \u003cinput name=\"user[name]\" value=\"Foo Bar\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"user-static\"\u003e\n \u003cinput name=\"users[0].title\" value=\"Mr.\"\u003e\n \u003cinput name=\"users[0].name\" value=\"John Do\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"user-dynamic\"\u003e\n \u003cinput name=\"users[0][title]\" value=\"Ms.\"\u003e\n \u003cinput name=\"users[0][name]\" value=\"Jane Do\"\u003e\n\u003c/div\u003e\n```\nconverted into\n```lua\n{\n name = {\n  \"Bar\",\n  \"Foo\"\n },\n user = {\n  title = \"Mr.\",\n  name = \"Foo Bar\"\n },\n users = {\n  {\n   title = \"Mr.\",\n   name = \"John Do\"\n  },\n  {\n   title = \"Ms.\",\n   name = \"Jane Do\"\n  }\n }\n}\n```\n\n[Back to TOC](#table-of-contents)\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2015, by Anton Heryanto Hasan.\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n[Back to TOC](#table-of-contents)\n\nSee Also\n========\n* [lua-resty-stack](https://github.com/antonheryanto/lua-resty-stack) \n* [lua-resty-upload](https://github.com/openresty/lua-resty-upload)\n* [lua-nginx-module](https://github.com/openresty/lua-nginx-module)\n\n[Back to TOC](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonheryanto%2Flua-resty-post","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonheryanto%2Flua-resty-post","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonheryanto%2Flua-resty-post/lists"}