{"id":13690102,"url":"https://github.com/dig/onset-http-library-java","last_synced_at":"2025-09-07T21:06:18.307Z","repository":{"id":99159989,"uuid":"230355540","full_name":"dig/onset-http-library-java","owner":"dig","description":null,"archived":false,"fork":false,"pushed_at":"2019-12-29T15:36:19.000Z","size":34,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-01T08:22:52.519Z","etag":null,"topics":[],"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/dig.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-27T02:02:34.000Z","updated_at":"2020-04-25T21:24:39.000Z","dependencies_parsed_at":"2023-06-04T08:00:14.690Z","dependency_job_id":null,"html_url":"https://github.com/dig/onset-http-library-java","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dig/onset-http-library-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dig%2Fonset-http-library-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dig%2Fonset-http-library-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dig%2Fonset-http-library-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dig%2Fonset-http-library-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dig","download_url":"https://codeload.github.com/dig/onset-http-library-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dig%2Fonset-http-library-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273709020,"owners_count":25153735,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-02T16:00:43.697Z","updated_at":"2025-09-07T21:06:18.257Z","avatar_url":"https://github.com/dig.png","language":"Lua","funding_links":[],"categories":["Packages and Plugins"],"sub_categories":["Libraries"],"readme":"# onset-http-library\nAuthors: Digital\n\n**NOTICE: This is no longer maintained, I've made a much better version in a c++ plugin which cuts out loading the JVM part. Check it out here: https://github.com/dig/onset-http-plugin. Since the c++ version does not have async, you can still use this one for async requests until its added.**\n\n### Features\n* Sync \u0026 Async.\n* GET, POST, PUT, HEAD, DELETE \u0026 PATCH requests.\n\n### Installation\n1. Create a folder inside your servers package folder called http, download all files from this repository and place them inside the http folder.\n1. Install \"http\" as a package inside server_config.json.\n1. Create a folder inside the root server directory called \"jars\", skip this if you already have one.\n1. Download onset-http-library.jar from Releases ([HERE](https://github.com/dig/onset-http-library/releases)) and place inside jars folder.\n1. Download OnsetJavaPlugin.dll (Windows) \u0026 OnsetJavaPlugin.so (Linux) from Releases ([HERE](https://github.com/dig/onset-http-library/releases)) and place inside plugins folder.\n1. Ensure Java 8 JDK/JRE 64bit is installed.\n1. Enable \"OnsetJavaPlugin\" as a plugin inside server_config.json.\n\n### Example\n```lua\nlocal http = ImportPackage('http')\n\n-- Synchronously send a get request to google.com and print its body\nlocal _res = http.Get('https://google.com')\nprint (_res.body)\n\n-- Synchronously send a post request to google.com and print the status code\nlocal _res = http.Post('https://google.com', {\n  authentication = \"bearer 123\"\n}, {\n  field1 = \"hi field1\",\n  lol = \"another field, any name as key\"\n})\nprint (_res.status)\n```\n\n### Functions\n#### SetTimeouts\nSets the timeouts for sockets and requests.\n```lua\nhttp.SetTimeouts(socketMs, requestMs)\n```\n* **socketMs** Socket timeout in milliseconds. Default is 60000ms. Example: 60000\n* **requestMs** Request timeout in milliseconds. Default is 10000ms. Example: 10000\n\n#### Get (Sync)\nSend a Get request.\n```lua\nhttp.Get(url, headers)\nhttp.Get(url, headers, params)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **params** Parameters to add to the request. Example: { apiKey = \"123\" }\n\nReturns a table with body, status and statusText. Nil if failed.\n```lua\n{\n  body = \"\",\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Get (Async)\nSend a Get request.\n```lua\nhttp.GetAsync(url, headers)\nhttp.GetAsync(url, headers, params)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **params** Parameters to add to the request. Example: { apiKey = \"123\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n#### Post (Sync)\nSend a Post request.\n```lua\nhttp.Post(url, headers, body)\nhttp.Post(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a table with body, status and statusText. Nil if failed.\n```lua\n{\n  body = \"\",\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Post (Async)\nSend a Post request.\n```lua\nhttp.PostAsync(url, headers, body)\nhttp.PostAsync(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n#### Put (Sync)\nSend a Put request.\n```lua\nhttp.Put(url, headers, body)\nhttp.Put(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a table with body, status and statusText. Nil if failed.\n```lua\n{\n  body = \"\",\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Put (Async)\nSend a Put request.\n```lua\nhttp.PutAsync(url, headers, body)\nhttp.PutAsync(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n#### Head (Sync)\nSend a Head request.\n```lua\nhttp.Head(url, headers)\nhttp.Head(url, headers, params)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **params** Parameters to add to the request. Example: { apiKey = \"123\" }\n\nReturns a table with status and statusText. Nil if failed.\n```lua\n{\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Head (Async)\nSend a Head request.\n```lua\nhttp.HeadAsync(url, headers)\nhttp.HeadAsync(url, headers, params)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **params** Parameters to add to the request. Example: { apiKey = \"123\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n#### Delete (Sync)\nSend a Delete request.\n```lua\nhttp.Delete(url, headers, body)\nhttp.Delete(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a table with body, status and statusText. Nil if failed.\n```lua\n{\n  body = \"\",\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Delete (Async)\nSend a Delete request.\n```lua\nhttp.DeleteAsync(url, headers, body)\nhttp.DeleteAsync(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n#### Patch (Sync)\nSend a Patch request.\n```lua\nhttp.Patch(url, headers, body)\nhttp.Patch(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a table with body, status and statusText. Nil if failed.\n```lua\n{\n  body = \"\",\n  status = 200,\n  statusText = \"OK\"\n}\n```\n\n#### Patch (Async)\nSend a Patch request.\n```lua\nhttp.PatchAsync(url, headers, body)\nhttp.PatchAsync(url, headers, fields)\n```\n* **url** The URL to send the request to. Example: https://google.com\n* **headers** Table of headers to send. Example: { myHeader = \"hi\", anotherHeader = \"lol\", authentication = \"bearer 123\" }\n* **body** String body, could be JSON. Example: \"Hello, I am the body of the POST request.\"\n* **fields** Same as above but table is automatically parsed to JSON. Example: { key = \"123\", name = \"Joseph\" }\n\nReturns a request ID which can be used with event OnAsyncHTTPRequest (see below for more information).\n\n### Events\n#### OnAsyncHTTPRequest\nCalled when a async request has either been successful or failed.\n```lua\nfunction OnAsyncHTTPRequest(id, requestType, error, body, status, statusText)\n  -- code here\nend\nAddEvent('OnAsyncHTTPRequest', OnAsyncHTTPRequest)\n```\n* **id** Unique identifier for the request you have sent. GetAsync \u0026 PostAsync will return a ID which can be compared to this. Example: 1\n* **requestType** 0 for GET, 1 for POST, 2 for PUT, 3 for HEAD, 4 for DELETE and 5 for PATCH.\n* **error** True for request failed, false for successful request.\n* **body** Request body, usually HTML.\n* **status** HTTP status code.\n* **statusText** Text version of the HTTP status code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdig%2Fonset-http-library-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdig%2Fonset-http-library-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdig%2Fonset-http-library-java/lists"}