{"id":50587339,"url":"https://github.com/coloz/async-http-library","last_synced_at":"2026-06-05T07:03:12.732Z","repository":{"id":337959738,"uuid":"1155525217","full_name":"coloz/async-http-library","owner":"coloz","description":"Non-blocking async HTTP client for Arduino UNO R4 WiFi and ESP32.","archived":false,"fork":false,"pushed_at":"2026-02-12T05:45:15.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-12T15:20:08.703Z","etag":null,"topics":["arduino","http"],"latest_commit_sha":null,"homepage":"https://aily.pro","language":"C++","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/coloz.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-11T16:00:46.000Z","updated_at":"2026-02-12T05:45:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/coloz/async-http-library","commit_stats":null,"previous_names":["coloz/async-http-library"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/coloz/async-http-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coloz%2Fasync-http-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coloz%2Fasync-http-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coloz%2Fasync-http-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coloz%2Fasync-http-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coloz","download_url":"https://codeload.github.com/coloz/async-http-library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coloz%2Fasync-http-library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33932048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"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":["arduino","http"],"created_at":"2026-06-05T07:03:11.217Z","updated_at":"2026-06-05T07:03:12.728Z","avatar_url":"https://github.com/coloz.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AsyncHTTP\n[中文](./README_ZH.md)  \n**Non-blocking async HTTP client library for Arduino UNO R4 WiFi and ESP32.**\n\n## Features\n\n- ✅ Supports **GET / POST / PUT / PATCH / DELETE / HEAD** requests\n- ✅ Supports sending **plain text** and **JSON** payloads\n- ✅ **Callback-based** async design — never blocks `loop()`\n- ✅ Up to **4 concurrent requests** (configurable)\n- ✅ Automatic parsing of response status code, headers, and body\n- ✅ Timeout control \u0026 global error callback\n- ✅ Compatible with **Arduino UNO R4 WiFi** and **ESP32**\n- ✅ HTTPS support on ESP32 (optional certificate verification skip)\n\n## Installation\n\n### Option 1: Manual Installation\n\nCopy the entire `arduino-async-http` folder to your Arduino libraries directory:\n\n- **Windows**: `Documents\\Arduino\\libraries\\AsyncHTTP\\`\n- **macOS**: `~/Documents/Arduino/libraries/AsyncHTTP/`\n- **Linux**: `~/Arduino/libraries/AsyncHTTP/`\n\n### Option 2: PlatformIO\n\nAdd to your `platformio.ini`:\n\n```ini\nlib_deps =\n    https://github.com/aily-project/arduino-async-http.git\n```\n\n## Quick Start\n\n```cpp\n#include \u003cAsyncHTTP.h\u003e\n\nAsyncHTTP http;\n\nvoid onResponse(const AsyncHTTPResponse\u0026 res, void* userData) {\n  Serial.print(\"Status: \");\n  Serial.println(res.statusCode());\n  Serial.println(res.body());\n}\n\nvoid onError(int code, const String\u0026 msg, void* userData) {\n  Serial.print(\"Error: \");\n  Serial.println(msg);\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  WiFi.begin(\"SSID\", \"PASSWORD\");\n  while (WiFi.status() != WL_CONNECTED) delay(500);\n\n  http.begin();\n  http.setTimeout(15000);\n  http.onError(onError);\n\n  // Send a non-blocking GET request\n  http.get(\"http://httpbin.org/get\", onResponse);\n}\n\nvoid loop() {\n  http.update();   // ← Must be called in loop()\n  // Other non-blocking code ...\n}\n```\n\n## API Reference\n\n### Initialization\n\n| Method | Description |\n|--------|-------------|\n| `http.begin()` | Initialize (auto-creates internal WiFiClient) |\n| `http.begin(clients[], count)` | Initialize with externally provided Client objects |\n| `http.setTimeout(ms)` | Set request timeout (default 10000ms) |\n| `http.setHeader(name, value)` | Add a global default header |\n| `http.clearHeaders()` | Clear all default headers |\n| `http.onError(callback)` | Set global error callback |\n\n### Sending Requests\n\nAll request methods **return immediately**. The return value is a request ID (≥0) or an error code (\u003c0).\n\n| Method | Description |\n|--------|-------------|\n| `http.get(url, callback)` | GET request |\n| `http.post(url, body, contentType, callback)` | POST request (custom Content-Type) |\n| `http.postJson(url, jsonBody, callback)` | POST JSON (`application/json`) |\n| `http.put(url, body, contentType, callback)` | PUT request |\n| `http.putJson(url, jsonBody, callback)` | PUT JSON |\n| `http.patch(url, body, contentType, callback)` | PATCH request |\n| `http.patchJson(url, jsonBody, callback)` | PATCH JSON |\n| `http.del(url, callback)` | DELETE request |\n| `http.request(method, url, body, ct, callback)` | Generic request method |\n\n### Callback Signatures\n\n```cpp\n// Success callback\nvoid onResponse(const AsyncHTTPResponse\u0026 response, void* userData);\n\n// Error callback\nvoid onError(int errorCode, const String\u0026 message, void* userData);\n```\n\n### AsyncHTTPResponse Object\n\n| Method | Return Type | Description |\n|--------|-------------|-------------|\n| `statusCode()` | `int` | HTTP status code (200, 404, …) |\n| `body()` | `const String\u0026` | Response body |\n| `isSuccess()` | `bool` | Status code is in the 200–299 range |\n| `header(name)` | `String` | Get a specific response header value |\n| `contentLength()` | `int` | Content-Length (-1 = unknown) |\n\n### Management\n\n| Method | Description |\n|--------|-------------|\n| `http.update()` | **Must** be called in `loop()` |\n| `http.pending()` | Returns the number of in-flight requests |\n| `http.abort(id)` | Cancel a specific request |\n| `http.abortAll()` | Cancel all requests |\n\n### Error Codes\n\n| Constant | Value | Description |\n|----------|-------|-------------|\n| `ASYNC_HTTP_ERR_POOL_FULL` | -1 | Request pool is full |\n| `ASYNC_HTTP_ERR_INVALID_URL` | -2 | Invalid URL |\n| `ASYNC_HTTP_ERR_CONNECT_FAIL` | -3 | Connection failed |\n| `ASYNC_HTTP_ERR_TIMEOUT` | -4 | Request timed out |\n| `ASYNC_HTTP_ERR_SEND_FAIL` | -5 | Send failed |\n| `ASYNC_HTTP_ERR_PARSE_FAIL` | -6 | Parse failed |\n\n## Compile-Time Configuration\n\nDefine macros **before** `#include \u003cAsyncHTTP.h\u003e` to override defaults:\n\n```cpp\n#define ASYNC_HTTP_MAX_REQUESTS    8     // Max concurrent requests (default 4)\n#define ASYNC_HTTP_BODY_BUF_SIZE   8192  // Response body buffer size (default 4096)\n#define ASYNC_HTTP_DEFAULT_TIMEOUT 30000 // Default timeout (default 10000ms)\n#define ASYNC_HTTP_MAX_HEADERS     32    // Max stored response headers (default 16)\n```\n\n## HTTPS Support\n\n| Platform | HTTPS |\n|----------|-------|\n| ESP32 | ✅ Supported (WiFiClientSecure) |\n| Arduino UNO R4 WiFi | ❌ HTTP only |\n\nESP32 enables `setInsecure()` by default (skips certificate verification) for development convenience. For production, configure CA certificates or fingerprint verification.\n\n## Examples\n\n- [BasicGet](examples/BasicGet/BasicGet.ino) — Basic GET request\n- [PostJson](examples/PostJson/PostJson.ino) — POST JSON data\n- [PostPlainText](examples/PostPlainText/PostPlainText.ino) — POST plain text\n- [MultipleRequests](examples/MultipleRequests/MultipleRequests.ino) — Multiple concurrent requests\n\n## How It Works\n\n```\nsetup():\n  http.begin()          → Initialize client pool\n  http.get(url, cb)     → Parse URL → Allocate slot → Enqueue (returns immediately)\n\nloop():\n  http.update()         → Iterate over all active slots:\n                            STATE_CONNECTING        → Attempt TCP connection\n                            STATE_SENDING           → Send HTTP request headers + body\n                            STATE_RECEIVING_HEADERS → Read and parse response headers byte by byte\n                            STATE_RECEIVING_BODY    → Read response body\n                            STATE_COMPLETE          → Fire callback → Release slot\n```\n\n## License\n\nMIT License © 2026 Aily Project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloz%2Fasync-http-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoloz%2Fasync-http-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloz%2Fasync-http-library/lists"}