mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-08-04 03:27:19 -04:00
Updated API HTTP (markdown)
parent
ac29a2470a
commit
900097c6ad
@ -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).
|
17
API-Internet.md
Normal file
17
API-Internet.md
Normal file
@ -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.
|
Loading…
x
Reference in New Issue
Block a user