AbortRemoteRequest
abortRemoteRequest
Requests cancellation of an HTTP request owned by the current server-side resource.
Syntax
bool abortRemoteRequest(number requestId)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
requestId |
number |
yes | The identifier returned by requestRemote.
|
Returns
Returns true when the owned request exists and cancellation was requested; otherwise returns false.
Examples
Cancel a request that is no longer needed:
local requestId = requestRemote(url, function(body, info)
if info.aborted then
outputDebugString("Request cancelled")
end
end)
if requestId then
abortRemoteRequest(requestId)
end
Notes
- Available only in server-side resource scripts.
- A resource can cancel only its own requests.
- Cancellation is cooperative. The completion callback is still delivered with
info.aborted = truewhen the resource remains running. - Stopping a resource cancels all HTTP requests owned by that resource and discards their callbacks.