Class: Transport

Transport

(abstract) new Transport()

The Transport class is the base class for providers of a HTTP transport layer.
A concrete implementation is required to implement Transport#post so that this method returns a Promise that will be resolved or rejected depending on the result of the underlying HTTP request
To create Promise instances, a Transport implementation should use a PromiseProvider. Client instances will automatically provide transports with the configured PromiseProvider as the promiseProvider property.
This level of abstraction allows users of the library to plug in their own implementation in order to use their favorite HTTP transport library. Implementations for Request and jQuery are provided.

Source:
See:

Methods

(abstract) post(url, headers, data, raw) → {Promise}

This method must be implemented by concrete Transport implementations in such a way that:

  • A HTTP POST request is made on url with the given headers and data (i.e.: payload)
  • A Promise is returned (this.promiseProvider will be available to create Promise instances)
  • The Promise is fulfilled when the HTTP request returns 200 (http://jmap.io/spec.html#jmap-over-https)
  • The Promise is rejected if the HTTP request fails, or if the return status code is not 200
  • When the Promise is fulfilled, the raw JMAP response is returned
Parameters:
Name Type Description
url String

The URL to POST to

headers Object

A hash of header names to header values that must be transmitted as part of the request

data *

The request payload, as a Javascript object. It's the responsibility of the Transport implementation to serialize the data as a JSON String whenever required.

raw Boolean

Whether the requests sends and expects raw (plain text) data instead of the default JSON.

Source:
Returns:
Type
Promise