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.contentwill be aString(this is the default and matches the current behavior) - "blob": (Client only)
result.contentwill be aBlob - "document": (Client only)
result.contentwill be aDocument - "buffer": (Server only)
result.contentwill be aBuffer(settingencodingtonulldoes the same thing) - "arraybuffer":
result.contentwill be anArrayBuffer - "ejson-binary":
result.contentwill be anEJSON.binary - "json":
result.contentwill be anObject
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.