method cancelAllRequests

void cancelAllRequests();

Argumente

Zurückgegebener Wert

This method cancels all outstanding requests, so the caller can destroy its listeners. This method enables the http service to be shutdown in an expedited manner.

The following example shows a request being issued, and then cancelAllRequests being called immediately after the request, to cancel the request.
var contextData = 1;
function main()
{
    var httpRequest = shell.serviceManager.http.request;
    var listener = new httpListener();  
    var context = new contextObject(contextData);
    httpRequest.get("http://search.aol.com", listener, context, 0);
    // cancel all pending HTTP requests
    httpRequest.cancelAllRequests(); 
}

function contextObject(num)
{
    this.num = num;
}

function httpListener()
{
    this.onResponse = onResponse;
    this.onError = onError;
}

function onResponse(requestor, code, text, header, payload, context)
{
    alert("The request returned code: " + code);
    alert("The status text for the return is: " + text);
  
    // the context value will match the 1 specified in the get
    alert("The context of this request is: " + context.num);

    // output the payload, to show the html for aol.com
    if (payload)
    {
        var streamReader = shell.serviceManager.basics.rawStreamReader;
        streamReader.stream = payload;
        var text = streamReader.readStringTillEndOfStream('');
        alert("The payload returned is: " + text); 
    }         

    // output a field from the returned header
    if (header)
    {
        // ** Note ** if Content-Length field does not exist, the following code will throw a JavaScript exception.
        var headerFieldArray = header.valueForKey("Content-Length");

        // use a 0 to get the first value, because the Content-Length header field only contains one value.
        var contentLength = headerFieldArray.getValue(0);
        if (contentLength)
        {
            alert("Content Length returned is: " + contentLength);
        }        
    }
}

function onError(requestor, code, context)
{
    alert("Http error: " + code);
}