This method closes a connection that was opened using the keepAlive flag.
Any URL that contains the host to which the connection was kept alive can be passed in as a parameter (eg. if "http://www.aol.com/foo" was used to open the connection, "http://www.aol.com/bar" or "http://www.aol.com" can be used to close it).
The following example shows a request being issued with the keepAlive flag, and then the keepAlive connection being closed at the end of the onResponse callback.var contextData = 1; var httpRequest; function main() { httpRequest = shell.serviceManager.http.request; var listener = new httpListener(); var context = new contextObject(contextData); // make a GET request with the keepAlive option on httpRequest.get("http://search.aol.com", listener, context, 1); } 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); } } // close the keepAlive request httpRequest.closeKeepAlive("http://search.aol.com"); httpRequest = null; } function onError(requestor, code, context) { alert("Http error: " + code); // close the keepAlive request httpRequest.closeKeepAlive("http://search.aol.com"); httpRequest = null; }