Class: HttpClient

HttpClient(appBaseUrlnon-null)

The HTTP client which performs the connection to the application server.

Constructor

new HttpClient(appBaseUrlnon-null)

Creates a new instance of HttpClient.
Parameters:
Name Type Description
appBaseUrl string an application base URL (the protocol and the domain name) represented as a string
Source:

Classes

HttpClient

Methods

headers(messagenon-null) → {Object}

Returns the string-typed map of HTTP header names to header values, which to use in order to send the passed message. In this implementation, returns {'Content-Type': 'application/x-protobuf'}.
Parameters:
Name Type Description
message TypedMessage a message to send, as a TypedMessage
Source:
Returns:
Type
Object

postMessage(endpointnon-null, messagenon-null) → {Promise.<(Response|Error)>}

Sends the given message to the given endpoint via `POST` request. The message is sent as in form of a Base64-encoded byte string.
Parameters:
Name Type Description
endpoint string a endpoint to send the message to
message TypedMessage a message to send, as a TypedMessage
Source:
See:
  • toBody
  • headers
Returns:
a message sending promise to be fulfilled with a response, or rejected if an error occurs
Type
Promise.<(Response|Error)>

requestMode(messagenon-null) → {string}

Returns the mode in which the HTTP request transferring the given message is sent. This implementation returns `cors`.
Parameters:
Name Type Description
message TypedMessage a message to send, as a TypedMessage
Source:
Returns:
the mode of HTTP requests to use
Type
string

toBody(messagenon-null) → (non-null) {string}

Transforms the given message to a string, which would become a POST request body. Uses Base64 encoding to transform the message.
Parameters:
Name Type Description
message TypedMessage a message to transform into a POST body
Source:
Returns:
transformed message
Type
string