{"id":21141610,"url":"https://github.com/bjornbytes/lovr-http","last_synced_at":"2025-07-09T05:32:06.806Z","repository":{"id":193384633,"uuid":"688678977","full_name":"bjornbytes/lovr-http","owner":"bjornbytes","description":"An HTTP library for Lua/LÖVR","archived":false,"fork":false,"pushed_at":"2024-03-28T19:47:19.000Z","size":52,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T00:44:05.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/bjornbytes.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}},"created_at":"2023-09-07T21:44:17.000Z","updated_at":"2024-05-02T00:44:05.013Z","dependencies_parsed_at":"2023-11-14T15:51:17.005Z","dependency_job_id":null,"html_url":"https://github.com/bjornbytes/lovr-http","commit_stats":null,"previous_names":["bjornbytes/lovr-http"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flovr-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flovr-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flovr-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flovr-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjornbytes","download_url":"https://codeload.github.com/bjornbytes/lovr-http/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225486674,"owners_count":17481947,"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":[],"created_at":"2024-11-20T07:32:21.945Z","updated_at":"2024-11-20T07:32:22.472Z","avatar_url":"https://github.com/bjornbytes.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"lovr-http\n===\n\nA Lua library for performing HTTP(S) requests.  It's basically a teeny tiny version of\n[lua-https](https://github.com/love2d/lua-https) included by default in [LÖVR](https://lovr.org).\nAlthough lovr's in the name, the library is self-contained and it should work in any Lua program.\n\nExample\n---\n\n```lua\nhttp = require 'http'\n\nstatus, data = http.request('https://zombo.com')\n\nprint('welcome')\nprint(status)\nprint(data)\n```\n\nAPI\n---\n\nThe module has one function:\n\n```lua\nstatus, data, headers = http.request(url, [options])\n```\n\n### Arguments\n\n`url` is the URL to request.  If it doesn't have a protocol, then `http://` will be added.\n\n`options` is optional, and is used for advanced request settings.\n\n`options.method` is the HTTP method to use, also called the verb.  `GET` is used by default if\nthere's no data in the request, otherwise it defauls to `POST`.  It will be converted to all-caps.\n\n`options.data` is the data to send to the server, also called the body.  It can be a few different\ntypes:\n\n- When `data` is nil, no request body will be sent (and `method` will default to `GET`).\n- When `data` is a string, the string will be used directly as the request body.\n- When `data` is a table, then pairs in the table will be URL encoded and concatenated together to\n  form an `application/x-www-form-urlencoded` body.  For example, if data is `{ n = 10, k = 'v!' }`,\n  then the request body will be something like `k=v%21\u0026n=10`.  Keys can appear in any order.  Table\n  pairs will only be used if the key is a string and the value is a string or number.\n- When `data` is a lightuserdata, the data pointed to by the lightuserdata will be used as the\n  request body.  Additionally, the `datasize` option should be an integer indicating how big the\n  request body is, in bytes.\n\nWhen `options.data` is set, the `Content-Type` request header will default to\n`application/x-www-urlencoded` unless it's set to something else.\n\n`options.headers` is a table of request headers to send to the server.  Pairs in the table will only\nbe used if the key is a string and the value is a string or number.\n\n### Returns\n\nIf an error occurs, the function returns `nil, errormessage`.\n\nOtherwise, 3 values are returned:\n\n- `status` is an integer with the HTTP status code (200 is OK, 404 is Not Found, etc.).\n- `data` is a string with the data sent by the server (HTML, JSON, binary, etc.).\n- `headers` is a table of response headers.\n\nLimitations\n---\n\n- `multipart/form-data` request bodies are not supported.\n- Multi-line response headers are not parsed correctly on all platforms.\n- There is no way to specify a request timeout, because not all platforms support it.\n- There is currently no way to limit or restrict HTTP redirects.  Redirects are generally followed.\n- Adding credentials in the URL is not supported.  Use the `Authorization` request header instead.\n- There are differences in behavior between platforms.  If you encounter any that are causing you\n  problems, please open an issue.\n- I don't even know what a proxy is but it's probably not going to work.\n\nCompiling\n---\n\nThe build system is CMake.  The CMake script doesn't have any logic to link against Lua yet, so it\nwill only build properly in LÖVR's `plugins` folder, where it will automatically use LÖVR's copy of\nLua.\n\nImplementation\n---\n\n`lovr-http` uses system-provided HTTP libraries:\n\n- Windows uses wininet.\n- Linux uses curl (must install e.g. `libcurl4` package, but most systems have it).\n- Android uses Java's HttpURLConnection via JNI.\n- macOS uses NSURLSession.\n\nThe system's certificates are used for HTTPS.\n\nLicense\n---\n\nMIT, see the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornbytes%2Flovr-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjornbytes%2Flovr-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornbytes%2Flovr-http/lists"}