Funzione statica
HTTP.Request
Makes a synchronous HTTP Request.<br/><br/>The request will be made synchronously and will freeze the server until it's done.
Non ancora tradotto
Sintassi
HTTP.Request(uri, endpoint = "", method = HTTPMethod.GET, data = "", content_type = application/json, compress = false, headers = {})
Parametri
| Nome | Tipo | Predefinito | Descrizione |
|---|---|---|---|
uri
|
string | — | The main URI (the base address) |
endpoint
facoltativo
|
string | "" |
The endpoint |
method
facoltativo
|
HTTPMethod | HTTPMethod.GET |
The HTTP Method to be used |
data
facoltativo
|
string | "" |
Payload |
content_type
facoltativo
|
string | application/json |
The <a href='https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types'>Content Type</a> to be used |
compress
facoltativo
|
boolean | false |
Whether or not to compress the content with gzip |
headers
facoltativo
|
table | {} |
The <a href='https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers'>Headers</a> to be used |
Valore restituito
-
table
Campi della tabella
StatusintegerDatastringHeaderstable
Esempi
local ret = HTTP.Request("127.0.0.1:7777", "/", HTTPMethod.GET, "", "application/json", false, {}),,Console.Log(ret.Status) -- 200,Console.Log(ret.Data) -- "{"players_count":0,"server_name":"nanos world server"}",Console.Log(ret.Headers["Content-Type"]) -- "application/json"