HPCloud-JS

API Docs for: 1.0.0
Show:

Transport Class

Defined in: lib/transport.js:28
Module: hpcloud

The transport layer that handles communications with the API endpoints.

Item Index

Methods

Methods

doRequest

(
  • opts
  • [body]
  • fn
)
static

Defined in lib/transport.js:38

Do an HTTPS request.

This performs a simple HTTPS request, and then executes the callback, passing the response object into the callback.

Parameters:

  • opts Object

    An object containing, at minimum, a parsed URL. To create a new opts, use URL.parse(url).

  • [body] String optional

    (Optional) The body of the request.

  • fn Function

    A callback function. This receives an Error (on error), a Response, and (if present) the data as a string.

doUnmanagedRequest

() static

Defined in lib/transport.js:99

Perform an HTTP request, but leave the data processing to something else.

This is useful for requests that result in large payloads, or for any cases where the response returned needs to be streamed to something else.

ObjectStorage is the quintessential use case.

fn(Error e, Stream response);

This will emit an error when the status code is 400 or above, but it does not manage redirects (3XX), 1XX and so on.

IMPORTANT: On errors, the Stream is still passed.