HTTP requests
PerformHttpRequest('https://api.example.com/status', function(status, body, headers, errorData) if status == 200 then local data = json.decode(body) print(data.message) else print('request failed', status, errorData) endend, 'GET', '', { ['Accept'] = 'application/json' })- Only server scripts can make HTTP requests.
- Methods:
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS. statusis0when there was no answer, for example on a timeout or a blocked address.bodyis set for successful answers. For errors,errorDataholds the error text or the error body.- Pass
{ timeout = 5000 }as the sixth argument to change the timeout (default 30 s).
Limits
Section titled “Limits”- Requests to private and local addresses (
127.0.0.1,10.x,192.168.x,localhostand similar) are blocked. Your server’s own network stays out of reach of scripts. - URLs with a user name or password are refused. Send credentials in a header.
- Request bodies are limited to 1 MB and responses to 16 MB. At most 32 requests per resource run at the same time.