WEB
This peripheral gives access into the Internet.
- Version: v1.0.0
- Available since: LIKO-12 v0.6.0
- Last updated in: LIKO-12 v0.8.0
Methods:
WEB.hasLuaSec
Checks if it has Luasec.
- Available since: WEB: v1.0.0, LIKO-12: v0.6.0
- Last updated in: WEB: v1.0.0, LIKO-12: v0.6.0
hasLuaSec = WEB.hasLuaSec()
Returns:
- hasLuaSec (boolean): True if it has LuaSec, false otherwise.
WEB.luasec
Load a luasec submodule.
- Available since: WEB: v1.0.0, LIKO-12: v0.6.0
- Last updated in: WEB: v1.0.0, LIKO-12: v0.6.0
submodule = WEB.luasec(name)
Arguments:
- <name> (string): Name of submodule to load.
Returns:
- submodule (table): The loaded submodule.
WEB.luasocket
Load a submodule.
- Available since: WEB: v1.0.0, LIKO-12: v0.6.0
- Last updated in: WEB: v1.0.0, LIKO-12: v0.6.0
submodule = WEB.luasocket(name)
Arguments:
- <name> (string): Name of submodule to load.
Returns:
- submodule (table): The loaded submodule.
WEB.send
Send a request to a URL.
- Available since: WEB: v1.0.0, LIKO-12: v0.6.0
- Last updated in: WEB: v1.0.0, LIKO-12: v0.6.0
requestID = WEB.send(url, args)
Arguments:
- <url> (string): URL to send request to.
- [args] (table) (Default:
nil
): Arguements to send in the request.
Returns:
- requestID (number): The request's id, used to read it later.
WEB.urlEncode
Encode a url to send it.
- Available since: WEB: v1.0.0, LIKO-12: v0.6.0
- Last updated in: WEB: v1.0.0, LIKO-12: v0.6.0
url = WEB.urlEncode(url)
Arguments:
- <url> (string): URL to encode.
Returns:
- url (string): The encoded URL.
Events:
Please note that the example functions won't be called automatically, there must be some kind of an events handler for CPU.pullEvent, check if the LIKO-12 OS you're using has one.
HTTP_Body
Triggered when a chunk of the HTTP response body is recieved.
- Available since: WEB: v1.0.0, LIKO-12: v1.0.0
- Last updated in: WEB: v1.0.0, LIKO-12: v1.0.0
function _HTTP_Body(requestID, chunk)
--Content run when the event is triggered
end
Arguments:
- requestID (number): The requestID returned by WEB.send().
- chunk (string): A chunk (part) of the response body, they're recieved in the correct order.
HTTP_Failed
Triggered when a HTTP request fails.
- Available since: WEB: v1.0.0, LIKO-12: v1.0.0
- Last updated in: WEB: v1.0.0, LIKO-12: v1.0.0
function _HTTP_Failed(requestID, reason)
--Content run when the event is triggered
end
Arguments:
- requestID (number): The requestID returned by WEB.send().
- reason (string): The reason of the request failure.
HTTP_Respond
Triggered when a HTTP response is received.
- Available since: WEB: v1.0.0, LIKO-12: v1.0.0
- Last updated in: WEB: v1.0.0, LIKO-12: v1.0.0
function _HTTP_Respond(requestID, response)
--Content run when the event is triggered
end
Arguments:
- requestID (number): The requestID returned by WEB.send().
- response (WEB/response): The content of the response.
Objects:
- response - The response table returnd when a HTTP response is received.