Internet: Difference between revisions
No edit summary |
No edit summary |
||
| Line 34: | Line 34: | ||
=== Handling responses === | === Handling responses === | ||
Upon making an HTTP(s) request you are provided with an <code>HttpResponseUD</code> object offering the following functionality.{{Navbox content}} | Upon making an HTTP(s) request you are provided with an <code>HttpResponseUD</code> object offering the following functionality. | ||
{| class="wikitable" | |||
|+ HttpResponseUD properties | |||
|- | |||
! Name !! Type !! Read/Write !! Description | |||
|- | |||
| <code>responseAvailable</code> || <code>bool</code> || READ || Returns whether this HTTP(s) request has been completed and therefore a response is available. | |||
|} | |||
{| class="wikitable" | |||
|+ HttpResponseUD methods | |||
|- | |||
! Name !! Returns !! Description | |||
|- | |||
|<code>:waitForCompletion()</code> | |||
|<code>void</code> | |||
|Blocks until <code>responseAvailable</code> is true. All other ''functions'' implicitly call this prior to executing and thus show the same behaviour. | |||
|- | |||
|<code>:getStatusCode()</code> | |||
|<code>int</code> | |||
|Returns the [[wikipedia:List_of_HTTP_status_codes|HTTP status]] code of the response. | |||
|- | |||
|<code>:waitForCompletion()</code> | |||
|<code>void</code> | |||
|Blocks until <code>responseAvailable</code> is true. All other ''functions'' implicitly call this and thus show the same behaviour. | |||
|- | |||
|<code>:waitForCompletion()</code> | |||
|<code>void</code> | |||
|Blocks until <code>responseAvailable</code> is true. All other ''functions'' implicitly call this and thus show the same behaviour. | |||
|} | |||
{{Navbox content}} | |||
Revision as of 11:39, 18 August 2026
The InternetUD component allows making real-world HTTP(s) requests. In order to be able to send HTTP(s) requests, make sure the current computer is connected to a WAN Router either directly via Network Cable or indirectly through Network Routers.
Security
By default, requests to local IP addresses are blocked (e.g. http://127.0.0.1). Domains are not filtered. You can allow access to local IPs by disabling the filtering in the config file.
If you wish, HTTP(s) functionality can also be disabled entirely in the config file. This completely removes the ability to make any kind of HTTP(s) requests.
API
| Name | Type | Read/Write | Description |
|---|---|---|---|
isHttpEnabled |
bool |
READ | Returns whether HTTP(s) is enabled at all. True by default, but can be changed in the server's config. Required to be true in order to use any methods. |
isConnectedToWan
|
bool
|
READ | Returns whether the current computer can reach a WAN router via the network. Required to be true in order to use any methods. |
| Name | Returns | Description |
|---|---|---|
:sendHttpRequest(url:string[, method:string[, postData:string[, headers:table]]])
|
HttpResponseUD
|
Asynchronously sends an HTTP(s) request to the given URL with the given request method (e.g. GET, POST, etc.).
If the request method is set to something supporting a post body, you may provide one as a string in |
Handling responses
Upon making an HTTP(s) request you are provided with an HttpResponseUD object offering the following functionality.
| Name | Type | Read/Write | Description |
|---|---|---|---|
responseAvailable |
bool |
READ | Returns whether this HTTP(s) request has been completed and therefore a response is available. |
| Name | Returns | Description |
|---|---|---|
:waitForCompletion()
|
void
|
Blocks until responseAvailable is true. All other functions implicitly call this prior to executing and thus show the same behaviour.
|
:getStatusCode()
|
int
|
Returns the HTTP status code of the response. |
:waitForCompletion()
|
void
|
Blocks until responseAvailable is true. All other functions implicitly call this and thus show the same behaviour.
|
:waitForCompletion()
|
void
|
Blocks until responseAvailable is true. All other functions implicitly call this and thus show the same behaviour.
|