{"id":16856441,"url":"https://github.com/vallentin/http_request","last_synced_at":"2025-03-18T11:14:23.675Z","repository":{"id":89082099,"uuid":"52761043","full_name":"vallentin/http_request","owner":"vallentin","description":"Wrapper for making HTTP requests with a single call","archived":false,"fork":false,"pushed_at":"2016-04-13T20:29:05.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T17:34:57.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/vallentin.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":"2016-02-29T03:25:17.000Z","updated_at":"2016-05-03T03:30:53.000Z","dependencies_parsed_at":"2023-06-13T21:09:18.916Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/http_request","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/vallentin%2Fhttp_request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fhttp_request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fhttp_request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fhttp_request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/http_request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244207746,"owners_count":20416109,"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-10-13T14:04:15.003Z","updated_at":"2025-03-18T11:14:23.668Z","avatar_url":"https://github.com/vallentin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# http_request\n\n*Wrapper for making HTTP requests in a single call*\n\nCurrently ported to:\n\n- [Python](https://github.com/MrVallentin/http_request/tree/master/python)\n- [Lua](https://github.com/MrVallentin/http_request/tree/master/lua)\n- [PHP](https://github.com/MrVallentin/http_request/tree/master/php)\n- [Java](https://github.com/MrVallentin/http_request/tree/master/java)\n- [JavaScript](https://github.com/MrVallentin/http_request/tree/master/javascript)\n\n\n## Python\n\nThe Python wrapper uses http.client and urllib.parse, which are standard libraries in Python.\n\n```python\nfrom http_request import *\n\n# The returned tuple contains (body, status, reason, headers)\n\ntuple http_request(url, data = None, method = \"GET\", headers = {})\n\ntuple http_head(url, data = None, headers = None)\ntuple http_get(url, data = None, headers = None)\ntuple http_post(url, data = None, headers = None)\ntuple http_delete(url, data = None, headers = None)\ntuple http_put(url, data = None, headers = None)\ntuple http_post(url, data = None, headers = None)\n```\n\n\n## Lua\n\nThe Lua wrapper uses [LuaSocket](http://w3.impa.br/~diego/software/luasocket/http.html).\n\n```lua\nlocal http = require(\"http_request\")\n\n-- If redirect is set to true, then response locations will be followed.\n\ntable http.request(string url [, string body = \"\" [, string method = \"GET\" [, table headers = {} [, boolean redirect = true]]]])\n\ntable http.get(string url [, string body = \"\" [, table headers = {} [, boolean redirect = true]]])\ntable http.post(string url [, string body = \"\" [, table headers = {} [, boolean redirect = true]]])\ntable http.delete(string url [, string body = \"\" [, table headers = {} [, boolean redirect = true]]])\ntable http.put(string url [, string body = \"\" [, table headers = {} [, boolean redirect = true]]])\ntable http.patch(string url [, string body = \"\" [, table headers = {} [, boolean redirect = true]]])\n\n-- The returned response table contains the following:\n-- response.headers\n-- response.body\n-- response.status\n-- response.code\n```\n\n\n## PHP\n\nThe PHP wrapper uses cURL, which was added (as a standard) in PHP 4.0.2.\n\n*Throws Exception on error.*\n\n```php\nstring http_request($url [, $data = null [, $method = \"GET\" [, array $headers = array()]]])\n\nstring http_get($url [, $data = null [, array $headers = array()]])\nstring http_post($url [, $data = null [, array $headers = array()]])\nstring http_delete($url [, $data = null [, array $headers = array()]])\nstring http_put($url [, $data = null [, array $headers = array()]])\nstring http_patch($url [, $data = null [, array $headers = array()]])\n```\n\n\n## Java\n\nThe Java wrapper uses the standard `java.io` and `java.net` packages.\n\n```java\n// All the following methods are found in com.vallentinsource.HTTPRequest\n\n// Default parameters aren't supported in Java, but it was more visually pleasing\n// to write the method once, than 4 times.\n\nstatic String request(\n\t\tString url,\n\t\tString data = null,\n\t\tString method \"GET\",\n\t\tMap\u003cString, String\u003e headers = null\n\t) throws MalformedURLException, IOException\n\nstatic String request(\n\t\tString url,\n\t\tMap\u003c?, ?\u003e data = null,\n\t\tString method \"GET\",\n\t\tMap\u003cString, String\u003e headers = null\n\t) throws MalformedURLException, IOException\n\n// The following get() method, exists along with a\n// post(), delete(), put() and patch().\n\nstatic String get(\n\t\tString url,\n\t\tString data = null,\n\t\tMap\u003cString, String\u003e headers = null\n\t) throws MalformedURLException, IOException\n\nstatic String get(\n\t\tString url,\n\t\tMap\u003c?, ?\u003e data = null,\n\t\tMap\u003cString, String\u003e headers = null\n\t) throws MalformedURLException, IOException\n\n```\n\n\n## JavaScript\n\n*The following is an example of what can be done.*\n\n```js\nhttp_request({\n\tmethod: \"POST\",\n\turl: \"http://example.com\",\n\tdata: {\n\t\tstr: \"Hello World!\",\n\t\tnum: 16,\n\t\tbool: true,\n\t\tarr: [ \"a\", \"b\", \"c\" ],\n\t\tobj: {\n\t\t\t\"a\": \"b\",\n\t\t\t\"c\": \"d\"\n\t\t}\n\t},\n\tsuccess: function(body, code, status)\n\t{\n\t\tconsole.log(\"Success: \" + code + \" \" + status);\n\t\tconsole.log(body);\n\t},\n\terror: function(body, code, status)\n\t{\n\t\tconsole.log(\"Error: \" + code + \" \" + status);\n\t\tconsole.log(body);\n\t}\n});\n```\n\n\n#### License\n\nThis module is shared under the MIT license, and is therefore free to use, share, distribute and modify.\nSee [LICENSE](https://github.com/MrVallentin/http_request/blob/master/LICENSE) for more details.\n\n\n[http_request]: https://github.com/MrVallentin/http_request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fhttp_request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fhttp_request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fhttp_request/lists"}