Internet: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
The InternetUD component allows making real-world [https://simple.wikipedia.org/wiki/Hypertext_Transfer_Protocol 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 Router|Network Routers]]. | |||
== Security == | |||
By default, requests to local IP addresses are blocked (e.g. <code><nowiki>http://127.0.0.1</nowiki></code>). Domains are not filtered. You can allow access to local IPs by disabling the filtering in the config file. | |||
{{Warning|Disabling this filtering will allow ingame computers to access webservices on the server's local machine (if any). This could pose a security threat if any of those local webservices assume local traffic to be trustworthy. Be careful!}} | |||
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 == | ||
{| class="wikitable" | |||
|+ InternetUD component properties | |||
|- | |||
! Name !! Type !! Read/Write !! Description | |||
|- | |||
| <code>isHttpEnabled</code> || <code>bool</code> || 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.''' | |||
|- | |||
|<code>isConnectedToWan</code> | |||
|<code>bool</code> | |||
|READ | |||
|Returns whether the current computer can reach a WAN router via the network. '''Required to be true in order to use any methods.''' | |||
|} | |||
{| class="wikitable" | |||
|+ InternetUD component methods | |||
|- | |||
! Name !! Returns !! Description | |||
|- | |||
|<code>:sendHttpRequest(url:string</code><code>[, method:string</code><code>[, postData:string</code><code>[, headers:table]]])</code> | |||
|<code>HttpResponseUD</code> | |||
|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 <code>postData</code>. Otherwise <code>postData</code> must be set to <code>""</code>. | |||
Headers may be provided as a table consisting of string keys and string values. | |||
'''The request method TRACE is not allowed for security reasons.''' | |||
|} | |||
=== Handling responses === | |||
Upon making an HTTP(s) request you are provided with an <code>HttpResponseUD</code> object offering the following functionality.{{Navbox content}} | |||
Revision as of 11:33, 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.