infinity.http¶
Povides HTTP client and server functionality.
Module: infinity.http
client¶
Allows for your instance of INFINITY.JS to act as an http-client. Lets you send requests and receive data.
Properties:
- allowUnsafeLegacyRenegotiation
- authMode
- charset
- contentDisposition
- contentLength
- contentType
- date
- etag
- expires
- handleProtocolErrorContent
- lastModified
- location
- maxContentLength
- password
- proxyPort
- proxyServer
- responseCharset
- responseCode
- responseText
- timeout
- useLegacyServerConnect
- userAgent
- username
- verifyServerCertificate
Methods:
- constructor()
- free()
- get()
- getAllRequestHeaders()
- getAllResponseHeaders()
- getFile()
- getRequestHeader()
- getResponseHeader()
- getStream()
- head()
- jsonRpc()
- options()
- patch()
- patchFile()
- patchStream()
- post()
- postFile()
- postMultipartFormData()
- postStream()
- put()
- putFile()
- putStream()
- remove()
- reset()
- setRequestHeader()
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client();
let html = myClient.get('http://localhost');
console.debug(html);
//<!doctype html>
//<html lang="de_DE"...
Properties
allowUnsafeLegacyRenegotiation¶
Type: boolean
Allows the deprecated ssl unsafe legacy renegotiation. This should be avoided and the server's ssl version should be fixed, instead. If that is not possible, then this option can be used to let the http client establish a connection nonetheless.
authMode¶
Type: infinity.http.client.authMode
Specifies the authentification mode for the connection to the server.
charset¶
Type: infinity.http.client.charset
Gets or sets the charset
value of the content-type
header.
contentDisposition¶
Type: string
Gets or sets the Content-Disposition
header value.
contentLength¶
Type: number
Gets the Content-Length
header value.
contentType¶
Type: string
Gets or sets the Content-Type
header value.
date¶
Type: number
Gets the Date
header value as a Unix-timestamp.
etag¶
Type: string
Gets the Etag
header value.
expires¶
Type: number
Gets the Expires
header value.
handleProtocolErrorContent¶
Type: boolean
If set to true
, then http error codes (http status codes 400 or higher) will no longer throw an exception. Instead, the responseCode
and responseText
properties will contain the http status code and body.
lastModified¶
Type: number
Gets the Last-Modified
header value as a Unix-timestamp.
location¶
Type: string
Gets the Location
header value.
maxContentLength¶
Type: number
If this property is set to a value other than zero (the default), then the client will truncate the server's response at the given maximum content length.
password¶
Type: string
Sets the password for the chosen authentification type.
proxyPort¶
Type: number
Sets the port number for the connection with a proxy.
proxyServer¶
Type: string
Sets the IP or URL address for the connection with a proxy.
responseCharset¶
Type: string
Specifies the character encoding of the response received from an HTTP request.
responseCode¶
Type: number
Gets the HTTP response code.
responseText¶
Type: string
Gets the HTTP response text.
timeout¶
Type: number
Sets the timeout for requests in milliseconds.
useLegacyServerConnect¶
Type: boolean
Allows deprecated, unsafe ssl connections. This should be avoided and the server's ssl version should be fixed, instead. If that is not possible, then this option can be used to let the http client establish a connection nonetheless.
userAgent¶
Type: number
Gets or sets the userAgent
header value.
username¶
Type: string
Sets the user name for the chosen authentification type.
verifyServerCertificate¶
Type: boolean
This option will turn on ssl certificate validation, which will result in a connection error if the server's ssl certificate is not valid (e.g. self-signed).
Methods
constructor()¶
Lets you create an INFINITY.JS HTTP client object instance. The optional async parameter determines whether the client operates in asynchronous or synchronous mode.
Signature:
constructor( async?: boolean )
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client();
free()¶
Frees the memory previously occupied by the HTTP client object instance.
Signature:
free(): void
Example:
myClient.free();
get()¶
Sends a GET
HTTP request for the given URL, including the previously set HTTP-headers.
Signature:
get( url: string ): string
Parameters:
- url:
string
The URL to send the request for.
Return type: string
Example:
let html = myClient.get('http://localhost');
console.debug(html);
get()¶
Sends a GET HTTP request for the given URL, including the previously set HTTP-headers, and uses the provided callback to handle the response.
Signature:
get( url: string, event: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request for.
-
event:
infinity.http.stringResponseEvent
A callback function that will be invoked when the GET request completes. This function will be called with two parameters: a string representing the response body (if successful) and an error string which will be non-empty if there was an error.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.get('http://localhost', (responseBody, error) => {
if (error) {
console.error("An error occurred:", error);
return;
}
console.debug(responseBody);
});
getAllRequestHeaders()¶
Returns an array containing the names of all set HTTP request headers.
Signature:
getAllRequestHeaders(): infinity.http.stringArray
Return type: infinity.http.stringArray
Example:
let html = myClient.get('http://localhost');
let requestHeaders = myClient.getAllRequestHeaders();
console.debug(requestHeaders);
getAllResponseHeaders()¶
Returns an array containing the names of all set HTTP response headers.
Signature:
getAllResponseHeaders(): infinity.http.stringArray
Return type: infinity.http.stringArray
Example:
let html = myClient.get('http://localhost');
let responseHeaders = myClient.getAllResponseHeaders();
console.debug(responseHeaders);
getFile()¶
Retrieves contents from the given URL and writes them to the file at the specified location.
Signature:
getFile( url: string, fileName: string ): void
Parameters:
-
url:
string
The URL from which the contents have to be saved.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the retrieved contents.
Example:
myClient.getFile('http://localhost', 'index.html');
getFile()¶
Retrieves contents from the given URL and writes them to the file at the specified location, and optionally uses the provided callback to notify when the downloading and saving process has completed or if an error has occurred.
Signature:
getFile( url: string, fileName: string, event: infinity.http.noResponseEvent ): void;
Parameters:
-
url:
string
The URL from which the contents have to be saved.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the retrieved contents.
-
event (optional):
infinity.http.noResponseEvent
A callback function that will be invoked once the download and save process is complete or if an error occurs. If specified, this function will be called with an error string which will be non-empty if there was an error during the process. If no error occurs, the function is invoked without any arguments.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.getFile('http://localhost/some-resource', 'downloaded-file.html', (error?) => {
if (error) {
console.error("An error occurred:", error);
return;
}
console.debug("File download and save completed successfully.");
});
getRequestHeader()¶
Returns the value of the specified HTTP request header.
Signature:
getRequestHeader( name: string ): string
Parameters:
- name:
string
The name of the request header to be examined.
Return type: string
Example:
let requestHeader = myClient.getRequestHeader('User-Agent');
console.debug(requestHeader);
getResponseHeader()¶
Returns the value of the specified HTTP response header.
Signature:
getResponseHeader( name: string ): string
Parameters:
- name:
string
The name of the response header to be examined.
Return type: string
Example:
let responseHeader = myClient.getResponseHeader('Expires');
console.debug(responseHeader);
getStream()¶
Writes received data from the specified URL to a given stream after sending a GET-request.
Signature:
getStream( url: string, stream: infinity.stream ): void
Parameters:
-
url:
string
The url to save from.
-
stream:
infinity.stream
The stream object to write to. See infinity.stream.
Example:
myClient.getStream(url, stream);
getStream()¶
Writes received data from the specified URL to a given stream after sending a GET-request, and optionally uses the provided callback to notify when the streaming process has completed or if an error has occurred.
Signature:
getStream( url: string, stream: infinity.stream, event?: infinity.http.noResponseEvent ): void;
Parameters:
-
url:
string
The url to save from.
-
stream:
infinity.stream
The stream object to write to. See infinity.stream.
-
event (optional):
infinity.http.noResponseEvent
A callback function that will be invoked once the streaming process is complete or if an error occurs. If specified, this function will be called with an error string which will be non-empty if there was an error during the streaming process. If no error occurs, the function is invoked without any arguments.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.getStream('https://localhost/data', myStream, (error?) => {
if (error) {
console.error("An error occurred:", error);
return;
}
console.debug("Data streaming completed successfully.");
});
head()¶
Sends a HEAD-request to the given URL and returns the response.
Signature:
head( url: string ): infinity.http.stringArray
Parameters:
- url:
string
The URL to send the request to.
Return type: infinity.http.stringArray
Example:
let headers = myClient.head('http://localhost');
console.debug(headers);
head()¶
Sends a HEAD-request to the given URL and uses the provided callback to handle the response.
Signature:
head( url: string, event: infinity.http.arrayResponseEvent ): void
Parameters:
- url:
string
The URL to send the request to.
- event:
infinity.http.arrayResponseEvent
A callback function that will be invoked when the HEAD request completes. This function will be called with two parameters: an array of strings representing the response (if successful) and an error string which will be non-empty if there was an error.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.head('http://localhost', (headers, error) => {
if (error) {
console.error("An error occurred:" + error);
return;
}
console.debug(headers);
});
jsonRpc()¶
Sends a JSON-RPC call to the specified URL and returns the response.
Signature:
jsonRpc( url: string, method: string, params?: infinity.http.paramArray, version?: infinity.http.client.version ): object
Parameters:
-
url:
string
The URL to send the request to.
-
method:
string
The remote procedure to be executed on the other endpoint.
-
params:
infinity.http.paramArray
, optionalThe parameters to be passed to the remote procedure.
-
version:
infinity.http.client.version
, optionalSpecifies the version of JSON-RPC to use.
Return type: object
Example:
let result = myClient.jsonRpc('https://team.greyhound-software.com/json', 'RpcInfoServer.GetServerInfo', [], infinity.http.client.version.jsonRpc1_1);
console.debug(JSON.stringify(result));
jsonRpc()¶
Sends a JSON-RPC call to the specified URL and uses an event callback to handle the response.
Signature:
jsonRpc( url: string, method: string, params?: infinity.http.paramArray, version?: infinity.http.client.version, event?: infinity.http.objectResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
method:
string
The remote procedure to be executed on the other endpoint.
-
params:
infinity.http.paramArray
, optionalThe parameters to be passed to the remote procedure.
-
version:
infinity.http.client.version
, optionalSpecifies the version of JSON-RPC to use.
-
event:
infinity.http.objectResponseEvent
, optionalA callback function that gets triggered upon receiving a response from the server or when an error ensues. This function takes in two parameters: the server's response as an object and an error object. Should the JSON-RPC call be successful, the error object will be null.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.jsonRpc('https://team.greyhound-software.com/json', 'RpcInfoServer.GetServerInfo', [], infinity.http.client.version.jsonRpc1_1, (response, error) => {
if (error) {
console.error("Error during the JSON-RPC request:", error.message);
return;
}
console.debug("Server responded with:", response);
});
options()¶
Sends a OPTIONS request to the given URL.
Signature:
options( url: string ): string;
Parameters:
- url:
string
The URL to send the request to.
Return type: string
Example:
myClient.options('http://localhost/');
options()¶
Sends an OPTIONS request to the specified URL. When provided, the optional callback function can be used to process the server's response or manage potential errors.
Signature:
options( url: string, event?: infinity.http.stringResponseEvent ): void;
Parameters:
- url:
string
The URL to send the request to.
- event:
infinity.http.stringResponseEvent
, optionalA callback function that is triggered upon receiving a response from the server or when an error arises. This function takes two arguments: the server's response string and an error string. In cases of successful operations, the error string will remain empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.options('http://localhost/api/', (response, error) => {
if (error) {
console.error("Error occurred during the OPTIONS request:", error);
return;
}
console.debug("Server responded with:", response);
});
post()¶
Sends a POST resquest to the given URL with the specified parameters.
Signature:
post( url: string, value: string, encoding?: infinity.encoding ): string
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The POST request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
Return type: string
Example:
let response = myClient.post('http://localhost/', "key=value&anotherkey=anothervalue");
console.debug(response);
post()¶
Sends a POST request to the given URL with the specified parameters and uses the provided callback to handle the server's response or any errors.
Signature:
post( url: string, value: string, encoding?: infinity.encoding, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The POST request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function that will be invoked once the server responds or if an error occurs. If specified, this function will be called with two arguments: the server's response string and an error string. If no error occurs, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.post('http://localhost/', "key=value&anotherkey=anothervalue", undefined, (response, error) => {
if (error) {
console.error("An error occurred:", error);
return;
}
console.debug("Server responded with:", response);
});
postFile()¶
Sends a POST request for uploading the specified file to the given URL.
Signature:
postFile( url: string, fileName: string ): string
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
Return type: string
Example:
let response = myClient.postFile('http://localhost/upload', "test.txt");
console.debug(response);
postFile()¶
Sends a POST request for uploading the specified file to the given URL and utilizes the provided callback to manage the server's response or potential errors.
Signature:
postFile( url: string, fileName: string, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function that will be invoked after the server responds or if an error arises. This function will be executed with two parameters: the server's response string and an error string. If no error takes place, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.postFile('http://localhost/upload', "test.txt", (response, error) => {
if (error) {
console.error("An error occurred during the file upload:", error);
return;
}
console.debug("Server responded with:", response);
});
postMultipartFormData()¶
Sends a multipart/form-data POST request to the given URL.
Signature:
postMultipartFormData( url: string, data: infinity.http.formDataArray ): string
Parameters:
-
url:
string
The URL to send the request to.
-
data:
infinity.http.formDataArray
An array containing the data to be uploaded.
Return type: string
Example:
let formData = [ { fieldName: 'fieldName1', fileName:'test.txt', fieldValue: 'fieldValue1', charset: 'ISO-8859-1', contentType: 'text/html' } ];
let response = myClient.postMultipartFormData('http://localhost/', formData);
console.debug(response);
postMultipartFormData()¶
Sends a multipart/form-data POST request to the specified URL and employs the provided callback to handle the server's response or potential errors.
Signature:
postMultipartFormData( url: string, data: infinity.http.formDataArray, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
data:
infinity.http.formDataArray
An array containing the data to be uploaded.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function that gets invoked once the server gives a response or in case an error pops up. This function receives two arguments: the server's response string and an error string. If no error is encountered, the error string will remain empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
let formData = [
{
fieldName: 'fieldName1',
fileName: 'test.txt',
fieldValue: 'fieldValue1',
charset: 'ISO-8859-1',
contentType: 'text/html'
}
];
myClient.postMultipartFormData('http://localhost/upload', formData, (response, error) => {
if (error) {
console.error("An error arose during form data submission:", error);
return;
}
console.debug("Server's response:", response);
});
postStream()¶
Sends a POST request for uploading the specified stream to the given URL.
Signature:
postStream( url: string, stream: infinity.stream ): string
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
Return type: string
Example:
myClient.postStream(url, stream);
postStream()¶
Sends a POST request for uploading the specified stream to the given URL and uses the provided callback to handle the server's response or any errors.
Signature:
postStream( url: string, stream: infinity.stream, event: infinity.http.stringResponseEvent ): void;
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
- event:
infinity.http.stringResponseEvent
, optionalA callback function that will be invoked once the server responds or if an error occurs. If specified, this function will be called with two arguments: the server's response string and an error string. If no error occurs, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.postStream('http://localhost/upload', stream, (response, error) => {
if (error) {
console.error("An error occurred while uploading:", error);
return;
}
console.debug("Server responded with:", response);
});
patch()¶
Sends a PATCH resquest to the given URL with the specified parameters.
Signature:
patch( url: string, value: string, encoding?: infinity.encoding ): string;
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The PATCH request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
Return type: string
Example:
let response = myClient.patch('http://localhost/', "patchRequestDataString");
console.debug(response);
patch()¶
Sends a PATCH request to the specified URL with the given parameters. When provided, the optional callback function can be utilized to process the server's response or to handle potential errors.
Signature:
patch( url: string, value: string, encoding?: infinity.encoding, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The PATCH request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function that is invoked when a response is received from the server or when an error emerges. This function takes two parameters: the server's response as a string and an error string. In scenarios where the operation is successful, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.patch('http://localhost/api/', "patchDataToUpdateResource", infinity.encoding.UTF8, (response, error) => {
if (error) {
console.error("Error encountered during the PATCH request:", error);
return;
}
console.debug("Server responded with:", response);
});
patchFile()¶
Sends a PATCH request for uploading the specified file to the given URL.
Signature:
patchFile( url: string, fileName: string ): string;
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
Return type: string
Example:
let response = myClient.patchFile('http://localhost/', "test.txt");
console.debug(response);
patchFile()¶
Sends a PATCH request for uploading a specified file to the provided URL. When the optional callback function is supplied, it can be employed to process the server's response or to address any potential errors during the upload process.
Signature:
patchFile( url: string, fileName: string, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
- event:
infinity.http.stringResponseEvent
, optionalA callback function that is triggered upon receiving a response from the server or when an error occurs. This function is designed to take two parameters: the server's response in the form of a string, and an error string. When the upload is successful, the error string will remain empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.patchFile('http://localhost/api/upload/', "test.txt", (response, error) => {
if (error) {
console.error("Error during the file PATCH request:", error);
return;
}
console.debug("Server responded with:", response);
});
patchStream()¶
Sends a PATCH request for uploading the specified stream to the given URL.
Signature:
patchStream( url: string, stream: infinity.stream ): string;
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
Return type: string
Example:
myClient.patchStream(url, stream);
patchStream()¶
Sends a PATCH request for uploading a specified stream to the provided URL. The optional event callback can be utilized to handle the server's response or to manage any potential issues during the stream upload process.
Signature:
patchStream( url: string, stream: infinity.stream, event?: infinity.http.stringResponseEvent ): void;
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
- event:
infinity.http.stringResponseEvent
, optionalA callback function activated upon obtaining a response from the server or when an error arises. This function accepts two arguments: the server's response as a string, and an error string. If the upload operation is successful, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.patchStream('http://localhost/api/upload/stream/', someStream, (response, error) => {
if (error) {
console.error("Error during the stream PATCH request:", error);
return;
}
console.debug("Server responded with:", response);
});
put()¶
Sends a PUT resquest to the given URL with the specified parameters.
Signature:
put( url: string, value: string, encoding?: infinity.encoding ): string;
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The PUT request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
Return type: string
Example:
let response = myClient.put('http://localhost/', "putRequestDataString");
console.debug(response);
put()¶
Sends a PUT request to the specified URL and uses the provided callback to manage the server's response or potential errors.
Signature:
put( url: string, value: string, encoding?: infinity.encoding, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
value:
string
The PUT request parameters.
-
encoding:
infinity.encoding
, optionalThe encoding for the request.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function activated upon obtaining a response from the server or when an error arises. This function accepts two arguments: the server's response as a string, and an error string. If the upload operation is successful, the error string will be empty.
Return type: string
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.put('http://localhost/resource', "putRequestDataString", undefined, (response, error) => {
if (error) {
console.error("Error occurred during PUT request:", error);
return;
}
console.debug("Server responded with:", response);
});
putFile()¶
Sends a PUT request for uploading the specified file to the given URL.
Signature:
putFile( url: string, fileName: string ): string;
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
Return type: string
Example:
let response = myClient.putFile('http://localhost/', "test.txt");
console.debug(response);
putFile()¶
Sends a PUT request to the specified URL to upload the file from the given path. If provided, the optional callback function can be used to handle the server's response or any potential errors.
Signature:
putFile( url: string, fileName: string, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file to be uploaded.
- event:
infinity.http.stringResponseEvent
, optionalA callback function that is invoked upon receiving a response from the server or when an error is encountered. This function receives two parameters: the server's response string and an error string. If the operation succeeds, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.putFile('http://localhost/upload', 'test.txt', (response, error) => {
if (error) {
console.error("Error occurred during the PUT file request:", error);
return;
}
console.debug("Server responded with:", response);
});
putStream()¶
Sends a PUT request for uploading the specified stream to the given URL.
Signature:
putStream( url: string, stream: infinity.stream ): string;
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
Return type: string
Example:
myClient.putStream(url, stream);
putStream()¶
Sends a PUT request to the specified URL to upload the provided stream. The specified callback function handles the server's response or potential errors.
Signature:
putStream( url: string, stream: infinity.stream, event?: infinity.http.stringResponseEvent ): void;
Parameters:
- url:
string
The url to save from.
- stream:
infinity.stream
The stream to be uploaded. See infinity.stream.
- event:
infinity.http.stringResponseEvent
, optionalA callback function that is invoked upon receiving a response from the server or when an error is encountered. This function receives two parameters: the server's response string and an error string. If the operation succeeds, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.putStream('http://localhost/upload', stream, (response, error) => {
if (error) {
console.error("Error occurred during the PUT stream request:", error);
return;
}
console.debug("Server responded with:", response);
});
remove()¶
Sends a DELETE request to the given URL.
Signature:
remove( url: string ): string;
Parameters:
- url:
string
The URL to send the request to.
Return type: string
Example:
myClient.remove('http://localhost/resource/123');
remove()¶
Sends a DELETE request to the specified URL. When provided, the optional callback function can be utilized to process the server's response or handle potential errors.
Signature:
remove( url: string, event?: infinity.http.stringResponseEvent ): void;
Parameters:
-
url:
string
The URL to send the request to.
-
event:
infinity.http.stringResponseEvent
, optionalA callback function that is invoked upon receiving a response from the server or when an error is encountered. This function accepts two parameters: the server's response string and an error string. In the event of a successful operation, the error string will be empty.
Example:
infinity.loadModule('infinity.http');
let myClient = new infinity.http.client(true);
myClient.remove('http://localhost/resource/123', (response, error) => {
if (error) {
console.error("Error occurred during the DELETE request:", error);
return;
}
console.debug("Server responded with:", response);
});
reset()¶
Resets the current object to the state of a newly instantiated INFINITY.JS client object.
Signature:
reset(): void;
Example:
myClient.reset();
setRequestHeader()¶
Sets the value of the specified header for future requests.
Signature:
setRequestHeader( name: string, value: string ): void
Parameters:
-
name:
string
The name of the header to be set.
-
value:
string
The value of the header to be set.
Example:
myClient.setRequestHeader('accept-encoding', 'gzip, deflate, br');
server¶
Allows for your instance of INFINITY.JS to act as an HTTP-server. Lets you receive requests and send data. Can register handlers for static files, REST requests, the JSON-RPC protocol and API calls (require the simultaneous usage of registerHandler() and registerService()). JSON-RPC and REST handlers can be combined in one service. Supports the range
HTTP header for streaming files. Supports the CalDAV, CardDAV and WebDAV protocol.
Methods:
Example for a static file server and status report functionality:
infinity.loadModule('infinity.http');
let myServer = new infinity.http.server(false, false, false, false, false, 80, 1024, 64, 104857600, 5.0);
myServer.registerHandler(infinity.http.server.handler.staticFile, '/', '../web/', 60.0, 256144);
myServer.registerHandler(infinity.http.server.handler.status, '/status');
myServer.start();
while (!infinity.terminated) {
infinity.event.processQueue();
infinity.sleep(25);
}
myServer.stop();
+ example
+ ts
- main.ts
+ web
- index.html
http://localhost/status
, or by a GET-request. Example for a server with custom options:
infinity.loadModule('infinity.http');
let myServer = new infinity.http.server(false, false, false, false, false, 80, 1024, 64, 104857600, 5.0);
myServer.registerHandler(infinity.http.server.handler.custom, '/custom', '/custom.js');
myServer.start();
while (!infinity.terminated) {
infinity.event.processQueue();
infinity.sleep(25);
}
myServer.stop();
custom.ts:
console.debug(infinity.http.request.httpAcceptEncoding);
infinity.http.response.contentType = 'text/plain; charset="utf-8"';
infinity.http.response.encoding = infinity.encoding.utf8;
infinity.http.response.contentText = 'Hello World! ü ö ä ß €';
Folder structure:
+ example
+ ts
- main.ts
- custom.ts
Can be viewed in a webbrowser under for example http://localhost/
or by a GET-request.
Example for a JSON-RPC endpoint with a custom defined service:
infinity.loadModule('infinity.http');
let myServer = new infinity.http.server();
myServer.registerHandler(infinity.http.server.handler.jsonRpc, '/v1/jsonrpc');
myServer.registerService('system', 'system', 'system.js', [
{name: 'shutdown'},
{name: 'getVersion', result: 'string'}
]);
myServer.start();
while (!infinity.terminated) {
infinity.event.processQueue();
infinity.sleep(25);
}
myServer.stop();
system.ts:
namespace system {
export function shutdown(): void {
infinity.terminate();
}
export function getVersion(): string {
return '1.0.0 build 1234';
}
}
Folder structure:
+ example
+ ts
- main.ts
- system.ts
Can be used by a POST-request
{"jsonrpc": "2.0", "method": "system.getVersion"}
http://localhost/v1/jsonrpc
. Example for a combined REST and JSON-RPC endpoint with a custom defined service:
infinity.loadModule('infinity.http');
let myServer = new infinity.http.server();
myServer.registerHandler(infinity.http.server.handler.staticFile, '/', '../web/');
myServer.registerHandler(infinity.http.server.handler.jsonRpc, '/v1/jsonrpc');
myServer.registerHandler(infinity.http.server.handler.rest, '/v1/rest');
myServer.registerService('users', 'users', 'users.js', [
{name: 'add', params: ['user: object'], result: 'number', rest: 'post'},
{name: 'put', params: ['user: object'], rest: 'put'},
{name: 'get', params: ['id: number'], result: 'object', rest: 'get'},
{name: 'list', result: 'array', rest: 'getList'},
{name: 'remove', params: ['id: number'], rest: 'delete'}
]);
myServer.start();
while (!infinity.terminated) {
infinity.event.processQueue();
infinity.sleep(25);
}
users.ts:
namespace users {
export function add(user: object): number {
console.debug('users.add: ' + JSON.stringify(user));
return 1;
}
export function put(user: object): void {
console.debug('users.put: ' + JSON.stringify(user));
}
export function get(id: number): object {
console.debug('users.get: ' + id);
return {id: 1, username: 'user1', name: 'The User Name'};
}
export function remove(id: number): void {
console.debug('users:remove: ' + id);
}
export function list(): Array<object> {
console.debug('users.list');
let users = [];
users.push({id: 1, username: 'user1', name: 'The User Name'});
users.push({id: 2, username: 'user2', name: 'Some User Name'});
users.push({id: 3, username: 'user3', name: 'Another User Name'});
return users;
}
}
Folder structure:
+ example
+ ts
- main.ts
- users.ts
http://localhost/v1/rest/users/1
or JSON-RPC POST-requests like {"jsonrpc": "2.0", "method": "users.get", "params": [1], "id": 1}
http://localhost/v1/jsonrpc
. Methods
constructor()¶
Lets you create an INFINITY.JS HTTP server object instance. Takes the most important parameters for the server to function.
Signature:
constructor( ssl?: boolean, verifyCertificate?: boolean, allowCrossOrigin?: boolean, compress?: boolean, accessLog?: boolean, port?: number, maxConnections?: number, poolSize?: number, maxContentLength?: number, slowRequestTime?: number, minProtocol?: infinity.http.server.protocol, maxProtocol?: infinity.http.server.protocol, maxRateCounter?: number )
Parameters:
-
ssl:
boolean
, optionalFor using SSL connections.
-
verifyCertificate:
boolean
, optionalWhether to verify the SSL-Certificate.
-
allowCrossOrigin:
boolean
, optionalFor allowing cross-origin-requests.
-
compress:
boolean
, optionalFor turning compression on or off.
-
accessLog:
boolean
, optionalFor turning on or off the logging of all access events.
-
port:
number
, optionalSpecifies the port to listen on.
-
maxConnections:
number
, optionalSpecifies the number of simultaneous connections.
-
poolSize:
number
, optionalSpecifies the number of worker threads to be held ready.
-
maxContentLength:
number
, optionalSpecifies the maximum number of bytes (content-length header) that the server accepts in http requests.
-
slowRequestTime:
number
, optionalSpecifies how many seconds the processing of a request is allowed to take without being logged as "slow". Accepts decimals with
.
as well. -
minProtocol:
infinity.http.server.protocol
, optionalThe minimum SSL/TLS version to support.
-
maxProtocol:
infinity.http.server.protocol
, optionalThe maximum SSL/TLS version to support.
-
maxRateCounter:
number
, optionalThe maximum number of requests that a client can make in a specific time frame for rate limiting.
Example:
infinity.loadModule('infinity.http');
let myServer = new infinity.http.server(false, false, false, false, true, 80, 1024, 64, 1024 * 1024, 5.0);
registerHandler()¶
Registers a handler for client requests, invoking additional resources, including caching functionality.
Signature:
registerHandler( handler: infinity.http.server.handler, path: string, alias: string, expire?: number, maxCacheSize?: number, headers?: infinity.http.headerArray, limit?: number, period?: number, delay?: number ): void
Parameters:
-
handler:
infinity.http.server.handler
The type of handler to register.
-
path:
string
The request path for the client.
-
alias:
string
The path to a local folder or file with contents or defined routines to be served corresponding to the client request.
-
expire:
number
, optionalThe cache expiration time in seconds. After the specified period the file will have to be examined for changes at the next call.
-
maxCacheSize:
number
, optionalThe cache threshold in bytes. Files with sizes exceeding the specified number will not be cached.
-
headers:
infinity.http.headerArray
The headers to be sent with the response.
-
limit:
number
, optionalThe maximum number of requests that can be made in the defined period. Used for rate limiting.
-
period:
number
, optionalThe rate limit time period in seconds.
-
delay:
number
, optionalThe "cool down" period in seconds that a client must wait after hitting the rate limit before making new requests.
Example:
myServer.registerHandler(infinity.http.server.handler.status, '/status', 1.0, 10.0, 3.0);
http.registerHandler(infinity.http.server.handler.staticFile, '/', '../web/', 60.0, 256144, [{name: "Cache-Control", value: "must-revalidate"}]);
Folder structure:
+ example
+ ts
- main.ts
+ web
- index.html
registerService()¶
Registers a service, allowing requests for execution of custom defined methods.
Signature:
registerService( name: string, namespace: string, path: string, methods: infinity.http.methodArray ): void
Parameters:
-
name:
string
The name of the service.
-
namespace:
string
The namespace for the service.
-
path:
string
The path to the file with the custom defined methods.
-
methods:
infinity.http.methodArray
An array of the method names for the service. Parameters for return types, REST methods and HTTP environment can also be specified.
Example:
myServer.registerHandler(infinity.http.server.handler.jsonRpc, '/v1/jsonrpc');
myServer.registerService('system', 'system', 'system.js', [
{name: 'shutdown'},
{name: 'getVersion', result: 'string'}
]);
system.ts:
namespace system {
export function shutdown(): void {
infinity.terminate();
}
export function getVersion(): string {
return '1.0.0 build 1234';
}
}
Folder structure:
+ example
+ ts
- main.ts
- system.ts
POST-request against /v1/jsonrpc
:
{"jsonrpc": "2.0", "method": "system.getVersion"}
setCertificate()¶
Sets the SSL certificate for the current server instance using the corresponding files provided in the function parameters.
Signature:
setCertificate(certFile: string, keyFile: string, rootCertFile?: string, verify?: boolean): void;
Parameters:
-
certFile:
string
The path to the certificate file to be used.
-
keyFile:
string
The path to the the key file to be used.
-
rootCertFile:
string
, optionalThe path to the the root certificate file to be used.
-
verify:
boolean
, optionalWhether to verify the validity of the certificate.
Example:
myServer.setCertificate('certFile.crt', 'keyFile.key', 'rootCertFile.crt', true);
start()¶
Starts the server instance with previously specified parameters.
Signature:
start(): void
Example:
myServer.start();
stop()¶
Shuts down the server instance.
Signature:
stop(): void
Example:
myServer.stop();
unregisterHandler()¶
Unregisters the specified registered handler, making the previously defined functionality unavailable.
Signature:
unregisterHandler( path: string ): void
Parameters:
- path:
string
The request path for the client, which the handler has previously been registered for.
Example:
myServer.unregisterHandler('/');
unregisterService()¶
Unregisters the specified registered service, making the previously defined functionality unavailable.
Signature:
unregisterService( name: string ): void
Parameters:
- name:
string
The name of the previously registered service.
Example:
myServer.unregisterService('system');
infinity.http.client¶
infinity.http.client.authMode¶
Values:
-
none:
0
None of the below.
-
basic:
1
Basic access authentication.
-
digest:
2
Digest access authentication.
Example:
infinity.loadModule('infinity.http');
let authMode = infinity.http.client.authMode.none;
infinity.http.client.version¶
Values:
-
jsonRpc1_1:
0
JSON-RPC version 1.1.
-
jsonRpc2_0:
1
JSON-RPC version 2.0.
Example:
infinity.loadModule('infinity.http');
let version = infinity.http.client.version.jsonRpc1_1;
infinity.http.request¶
Read-only properties containing information from the incoming HTTP request.
- contentBoundary
- contentDisposition
- contentEncoding
- contentFilename
- contentLength
- contentText
- contentTransferEncoding
- contentType
- cookies
- destination
- files
- gatewayInterface
- get
- httpAccept
- httpAcceptCharSet
- httpAcceptEncoding
- httpAcceptLanguage
- httpAuthorization
- httpConnection
- httpHost
- httpIfMatch
- httpIfModifiedSince
- httpIfNonMatch
- httpReferer
- httpUserAgent
- method
- pathInfo
- pathTranslated
- post
- range
- remoteAddr
- remoteHost
- remoteIdent
- remotePort
- remoteUser
- scgi
- scheme
- scriptFilename
- scriptName
- serverAddr
- serverAdmin
- serverName
- serverPort
- serverProtocol
- serverSignature
- serverSoftware
- uri
contentBoundary¶
Type: string
contentDisposition¶
Type: string
Gets the content-disposition
HTTP-header value.
contentEncoding¶
Type: infinity.encoding
Gets the content-encoding
HTTP-header value.
contentFilename¶
Type: string
Gets the filename parameter of the Content-Disposition
HTTP-header value.
contentLength¶
Type: number
Gets the content-length
HTTP-header value.
contentText¶
Type: string
Gets the contents of the body of the request.
contentTransferEncoding¶
Type: string
Gets the transfer-encoding
HTTP-header value.
contentType¶
Type: string
Gets the content-type
HTTP-header value.
cookies¶
Type: infinity.http.cookiesArray
Gets cookie data.
destination¶
Type: string
Gets the destination of the HTTP request
files¶
Type: infinity.http.filesArray
Gets information about the files sent with the HTTP request.
gatewayInterface¶
Type: string
Gets the name and version of the gateway interface (only during SCGI operations).
get¶
Type: infinity.http.valuesArray
Gets the information out of the GET-part of the HTTP request.
httpAccept¶
Type: string
Gets the accept
HTTP-header value.
httpAcceptCharSet¶
Type: string
Gets the accept-charset
HTTP-header value.
httpAcceptEncoding¶
Type: string
Gets the accept-encoding
HTTP-header value.
httpAcceptLanguage¶
Type: string
Gets the accept-language
HTTP-header value.
httpAuthorization¶
Type: string
Gets the authorization
HTTP-header value.
httpConnection¶
Type: string
Gets the connection
HTTP-header value.
httpHost¶
Type: string
Gets the Host
value of the HTTP request.
httpIfMatch¶
Type: string
Gets the if-match
HTTP-header value.
httpIfModifiedSince¶
Type: number
Gets the if-modified-since
HTTP-header value.
httpIfNonMatch¶
Type: string
Gets the if-none-match
HTTP-header value.
httpReferer¶
Type: string
Gets the referer
HTTP-header value.
httpUserAgent¶
Type: string
Gets the user-agent
HTTP-header value.
method¶
Type: string
Gets the HTTP request method.
pathInfo¶
Type: string
Reports the value of the path information (if any) of the URL specified in the HTTP request message.
pathTranslated¶
Type: string
Represents a translation of the PathInfo
property to a fully qualified path on the Web server.
post¶
Type: infinity.http.valuesArray
Gets the information out of the POST-part of the HTTP request.
range¶
Type: infinity.http.rangeArray
Gets the range
HTTP-header value.
remoteAddr¶
Type: string
Gets the IP address of the remote machine making this request.
remoteHost¶
Type: string
Gets the hostname of the remote machine making this request (only during SCGI operations).
remoteIdent¶
Type: string
Gets the remote user name retrieved from the server (only during SCGI operations).
remotePort¶
Type: number
Gets the port over which the remote machine communicates.
remoteUser¶
Type: string
Gets the authenticated remote user name (only during SCGI operations).
scgi¶
Type: boolean
Indicates whether scgi is being used.
scheme¶
Type: string
Gets the :scheme:
HTTP-header value.
scriptFilename¶
Type: string
Gets the filename of the script being executed (only during SCGI operations).
scriptName¶
Type: string
Gets the name of the script being executed.
serverAddr¶
Type: string
Gets the local server address.
serverAdmin¶
Type: string
Gets or sets server administrator information (only during SCGI operations).
serverName¶
Type: string
Gets the domain name of the local server.
serverPort¶
Type: number
Gets the port over which the local server communicates.
serverProtocol¶
Type: string
Gets the protocol over which the local server communicates.
serverSignature¶
Type: string
Gets the signature of the local server (only during SCGI operations).
serverSoftware¶
Type: string
Gets the name representing the local server software.
uri¶
Type: string
Gets the URI of the HTTP request.
infinity.http.response¶
The properties of the outgoing response from the INFINITY.JS server. Can be read and set. Undefined, unless used inside the file specified in the "alias" parameter of registerHandler().
acceptRanges¶
Type: string
Gets or sets the accept-ranges
HTTP-header value.
cacheControl¶
Type: string
Gets or sets the cache-control
HTTP-header value.
code¶
Type: number
Gets or sets the HTTP response code.
contentEncoding¶
Type: string
Gets or sets the content-encoding
HTTP-header value.
contentFilename¶
Type: string
Gets or sets the filename parameter of the content-disposition
HTTP-header value.
contentLanguage¶
Type: string
Gets or sets the content-language
HTTP-header value.
contentRange¶
Type: string
Gets or sets the content-range
HTTP-header value.
contentStream¶
Type: infinity.stream
Gets or sets the contents of the body of the response using a infinity.stream.
contentText¶
Type: string
Gets or sets the contents of the body of the response.
contentType¶
Type: string
Gets or sets the content-type
HTTP-header value.
cookies¶
Type: infinity.http.cookiesArray
Gets or sets cookie data.
date¶
Type: number
Gets or sets the date
HTTP-header value.
encoding¶
Type: infinity.encoding
Gets or sets the encoding of the HTTP response.
etag¶
Type: string
Gets or sets the etag
HTTP-header value.
expires¶
Type: number
Gets or sets the expires
HTTP-header value.
headers¶
Type: infinity.http.valuesArray
Gets or sets additional headers inside a valuesArray.
ignoreSlowRequest¶
Type: boolean
Gets or sets the setting for not logging the request if it takes longer than the slowRequestTime setting, set during the server instance creation.
lastModified¶
Type: number
Gets or sets the last-modified
HTTP-header value.
location¶
Type: string
Gets or sets the location
HTTP-header value.
pragma¶
Type: string
Gets or sets the pragma
HTTP-header value.
proxyAuthenticate¶
Type: string
Gets or sets the proxy-authenticate
HTTP-header value.
refresh¶
Type: string
Gets or sets the undocumented refresh
HTTP-header value.
server¶
Type: string
Gets or sets the server
HTTP-header value.
transferEncoding¶
Type: string
Gets or sets the transfer-encoding
HTTP-header value.
wwwAuthenticate¶
Type: string
Gets or sets the WWW-Authenticate
HTTP-header value.
infinity.http.server¶
infinity.http.server.handler¶
Values:
-
custom:
0
A custom handler to be defined in a file, specified in the third function parameter of registerHandler().
-
staticFile:
1
A handler for serving static file content. Prefers showing the index.html file.
-
jsonRpc:
2
A handler for requests according to the JSON-RPC protocol.
-
rest:
3
A handler for REST-requests.
-
api:
4
A handler for requests to an API.
-
webDav:
5
A handler for requests according to the WebDAV protocol (not implemented yet).
-
cardDav:
6
A handler for requests according to the CardDAV protocol (not implemented yet).
-
calDav:
7
A handler for requests according to the CalDAV protocol (not implemented yet).
-
status:
8
A handler for server-status requests, showing server and resource usage information.
Example:
infinity.loadModule('infinity.http');
let handler = infinity.http.server.handler.custom;
infinity.http.server.protocol¶
Values:
-
tls1_0:
2
Specifies the usage of TLS 1.0.
-
tls1_1:
3
Specifies the usage of TLS 1.1.
-
tls1_2:
4
Specifies the usage of TLS 1.2.
-
tls1_3:
5
Specifies the usage of TLS 1.3.
Example:
infinity.loadModule('infinity.http');
let protocol = infinity.http.server.protocol.tls1_2;
arrayResponseEvent¶
Signature:
(response: Array<string>, error: string): void
A callback function type used to handle the response from asynchronous HTTP requests. The callback receives the response as an array of strings and an error message if an error occurs during the request.
Properties:¶
-
response¶
Type:
Array<string>
. An array containing the response data, such as headers or other string-based data. -
error¶
Type:
string
. An error message that will be non-empty if there was an error during the HTTP request. If the request was successful, this value will be an empty string.
cookiesArray¶
Extends: Array<{name: string, value: string, expires: number, path: string, domain: string}>
An array containing objects with cookie data inside its properties.
Properties:¶
-
name¶
Type:
string
. The name of a cookie field. -
value¶
Type:
string
. The value of a cookie field. -
expires¶
Type:
number
. The expiration date for the cookie. -
path¶
Type:
string
. The storage path for the cookie. -
domain¶
Type:
string
. The domain the cookie is set from.
filesArray¶
Extends: Array<{controlName: string, fileName: string, tempFilename: string, size: number, contentType: string}>
An array containing objects with data inside its properties.
Properties:¶
-
controlName¶
Type:
string
. The name of the used HTML form control. -
fileName¶
Type:
string
. The name of the file. -
tempFilename¶
Type:
string
. The temporary filename, the file is available under. Is only set during the actual request. -
size¶
Type:
number
. The size of the file. -
contentType¶
Type:
string
. The MIME-Type of the file.
formDataArray¶
Extends: Array<{fieldName: string, fileName: string, fieldValue: string, charset: string, contentType: string}>
An array containing objects with data inside its properties.
Properties:¶
-
fieldName¶
Type:
string
. The name of a form field. -
fileName¶
Type:
string
. The name of a file attachment transmitted with the form data. -
fieldValue¶
Type:
string
. The value of a form field. -
charset¶
Type:
string
. The character encoding of the transmission. -
contentType¶
Type:
string
. The MIME-Type of the transmission.
headerArray¶
Extends: Array<{name: string, value: string}>{}
An array of objects containing name-value string pairs.
methodArray¶
Extends: Array<{name: string, params?: Array<string>, result?: any, rest?: string, httpEnvironment?: boolean}>
An array containing objects with data inside its properties.
Properties:¶
-
name¶
Type:
string
. The name of the function. -
params¶
Type:
Array<string>
, optional. The function parameters. -
result¶
Type:
any
, optional. The return type of the function result. -
rest¶
Type:
string
, optional. The implied REST method for the function call. -
httpEnvironment¶
Type:
boolean
, optional. If set to true, theinfinity.http.request
values will be provided.
paramArray¶
Extends: Array<any>
An array of data of any type.
rangeArray¶
Extends: Array<{firstOffset: number, lastOffset: number}>
An array containing objects with data inside its properties.
Properties:¶
noResponseEvent¶
Signature:
( error: string ):
A callback function type designed for asynchronous HTTP requests that don't expect a response. The callback receives only an error message in case an error occurs during the request.
Properties:¶
-
error¶
Type:
string
. An error message that will be non-empty if there was an error during the HTTP request. If the request was successful, this value will be an empty string.
stringArray¶
Extends: Array<string>
An array of strings.
stringResponseEvent¶
Signature:
( response: string, error: string ): void
A callback function type tailored for asynchronous HTTP requests that expect a string as a response. The callback receives the response as a string and an error message if an error arises during the request.
Properties:¶
-
response¶
Type:
string
. A string containing the response data from the server. -
error¶
Type:
string
. An error message that will be non-empty if there was an error during the HTTP request. If the request was successful, this value will be an empty string.
objectResponseEvent¶
Signature:
( response: object, error: string ): void
A callback function type crafted for asynchronous HTTP requests that expect an object as a response. The callback gets the response as an object and an error message if an error transpires during the request.
Properties:¶
-
response¶
Type:
object
. The object encapsulating the response data, such as JSON data or any structured data returned from the server. -
error¶
Type:
string
. An error message that will be non-empty if there was an error during the HTTP request. If the request was successful, this value will be an empty string.
valuesArray¶
Extends: Array<{name: string, value: string}>
An array containing objects with data inside its properties.