Skip to main content

httprequest.cancel()

Cancels an HTTP request sent asynchronously

Availability

Agent

Returns

Nothing

Description

This method cancels an httprequest object created using http.get(), http.httpdelete(), http.post(), http.put() or http.request() and sent asynchronously using httprequest.sendasync().

Once httprequest.cancel() is called, neither of the two callback functions registered using httprequest.sendasync() — one mandatory, the other optional — will be invoked, and no data will be returned. As such, you will not know whether the HTTP request was successful or not.

HTTP requests issued synchronously using httprequest.sendsync() can’t be cancelled: sendsync() does not return until the remote resource responds or the request times out.