Function “requestHTTP”
function requestHTTP(method, url[, headers, body])
Performs a HTTP request
Performs a HTTP request and returns the reply as an object.
Parameters
| Name | Type | Description |
|---|---|---|
method | string | The HTTP method to use (e.g. "GET" or "POST") |
url | string | The URL to request |
headers | array of values (optional) | An optional array of key/value objects to pass as additional request headers |
body | array of bytes (optional) | Optional contents for the request body |
Return Value
Returns an object with the fields statusCode, headers and body.
Example
try {
res = requestHTTP("GET", "http://bildhuus.com/");
if (res.statusCode == 200)
alert("bildhuus.com is reachable and OK");
else
alert("bildhuus.com is reachable, but returned " + res.statusCode);
} catch (err) {
alert("bildhuus.com is not reachable: " + err);
}