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