diff --git a/API-HTTP.md b/API-HTTP.md new file mode 100644 index 0000000..41db163 --- /dev/null +++ b/API-HTTP.md @@ -0,0 +1,9 @@ +This library wraps wireless modems' HTTP capability in a function that returns an iterator over the lines of the request result. + +- `http.request(url: string[, data: string or table]): function` + Sends an HTTP request to the specified URL, with the specified POST data, if any. If no data is specified, a GET request will be made. The POST data can be in one of two formats: if it's a string, it will be sent as-is. If it's a table, it will be converted to a string by assuming that each key is the name of a POST variable, and it's associated value is the value for that variable. So, for example: + `http.request(url, {some = "variable", another = 1})` + Will send `some=variable&another=1`. + The returned function is an iterator over the lines of the result, use it like so: + `for line in http.request(...) do stuff() end` + **Important**: you should not call `os.sleep`, `event.pull` or any other functions that directly or indirectly consume signals while iterating the result lines, since the lines of the response are one signal each (to avoid running out of memory for large results). \ No newline at end of file