Library http
HTTP library, allows sending HTTP requests.
Functions
| canRequest() | Returns whether a request can be made at the moment, taking into account permissions and the rate limit. |
| cooldownTime() | Returns how long (in seconds) until the next request is allowed. |
| fetch( url, onSuccess, onFailed, headers ) | Performs a GET request. |
| maxRequestsPerSecond() | Returns the maximum number of HTTP requests that are allowed per second. |
| nextRequest() | Returns the timestamp at which you can next run a request, relative to time.sysTime(). |
| post( url, params, onSuccess, onFailed, headers ) | Performs a form-encoded POST request. |
| sendRequest( request ) | Sends an HTTP request. |
Functions
- http.canRequest()
-
Returns whether a request can be made at the moment, taking into account permissions and the rate limit.
Environment:
Shared - http.cooldownTime()
-
Returns how long (in seconds) until the next request is allowed.
Environment:
Shared - http.fetch( url, onSuccess, onFailed, headers )
-
Performs a GET request. Requires the SEND_HTTP_REQUESTS permission to be granted when used on the client side.
Environment:
SharedParameters:
-
(string) url: The URL to request. -
(function) onSuccess: Function to run on success. It's passed the response body, a table of header values, and the response code. -
(function) onFailed: Function to run on failure. It's passed an error message explaining the failure. -
(table: An optional table of headers to include in the request (keys and values must be strings).?) headers
Return values:
-
(boolean)True if the request fired, false otherwise. -
(string)If the request did not fire, the reason why.
-
- http.maxRequestsPerSecond()
-
Returns the maximum number of HTTP requests that are allowed per second.
Environment:
Shared - http.nextRequest()
-
Returns the timestamp at which you can next run a request, relative to time.sysTime().
Environment:
Shared - http.post( url, params, onSuccess, onFailed, headers )
-
Performs a form-encoded POST request. Requires the SEND_HTTP_REQUESTS permission to be granted when used on the client.
Environment:
SharedParameters:
-
(string) url: The URL to request. -
(table: The table of parameters to send as the (form-encoded) body of the POST request.) params -
(function) onSuccess: The function to run on success. It's passed the response body, a table of header values, and the response code. -
(function) onFailed: Function to run on failure. It's passed an error message explaining the failure. -
(table: An optional table of headers to include in the request (keys and values must be strings).?) headers
Return values:
-
(boolean)True if the request fired, false otherwise. -
(string)If the request did not fire, the reason why.
-
- http.sendRequest( request )
-
Sends an HTTP request. Unlike fetch() and post(), this allows defining all parameters of a request, including the body and method. Requires the SEND_HTTP_REQUESTS permission to be granted when used on the client.
Environment:
SharedParameters:
-
(HTTPRequest) request: The request to send.
Return values:
-
(boolean)True if the request fired, false otherwise. -
(string)If the request did not fire, the reason why.
-