aldeed:http

v0.2.3Published 6 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

http-extras

IMPORTANT: This package is no longer maintained. Now that Meteor apps can use NPM packages directly, I recommend using a more standards-based package such as isomorphic-fetch rather than Meteor's HTTP package.

Adds the features proposed in this PR. Add this to your project along with the core http package.

Installation

In a Meteor app directory, enter:

meteor add http aldeed:http

Details

The API methods are the same as in the core HTTP package.

This package adds a responseType option to HTTP.call on both the client and the server. It also adds an encoding option on the server.

The responseType option can be one of the following string values:

  • "string": result.content will be a String (this is the default and matches the current behavior)
  • "blob": (Client only) result.content will be a Blob
  • "document": (Client only) result.content will be a Document
  • "buffer": (Server only) result.content will be a Buffer (setting encoding to null does the same thing)
  • "arraybuffer": result.content will be an ArrayBuffer
  • "ejson-binary": result.content will be an EJSON.binary
  • "json": result.content will be an Object

On the server only, you may additionally specify the desired encoding with the encoding option when responseType is "string". This takes string values matching those from Node's Buffer.toString method.

License Note

The LICENSE covers my additions and changes. Much of the code is copied from Meteor's core http package.