From 900097c6adf3d680b163fc849f47ca8bc97b3738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Thu, 6 Mar 2014 00:32:53 -0800 Subject: [PATCH] Updated API HTTP (markdown) --- API-HTTP.md | 9 --------- API-Internet.md | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 API-HTTP.md create mode 100644 API-Internet.md diff --git a/API-HTTP.md b/API-HTTP.md deleted file mode 100644 index 41db163..0000000 --- a/API-HTTP.md +++ /dev/null @@ -1,9 +0,0 @@ -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 diff --git a/API-Internet.md b/API-Internet.md new file mode 100644 index 0000000..b5cc892 --- /dev/null +++ b/API-Internet.md @@ -0,0 +1,17 @@ +This library wraps functionality of Internet cards. + +- `internet.isHttpEnabled():boolean` + Returns whether HTTP requests are allowed on the server (config setting). +- `internet.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: + `internet.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 internet.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). +- `internet.isTcpEnabled():boolean` + Returns whether TCP sockets are allowed on the server (config setting). +- `internet.connect(address:string[, port:number]):number` + Opens a new TCP connection. Returns the handle of the connection. The returned handle can be used to interact with the opened socket using the other callbacks. This can error if TCP sockets are not enabled, there are too many open connections or some other I/O error occurs. +- `internet.close(handle:number)` + Closes the socket with the specified handle. \ No newline at end of file