restjs-api
Advanced tools
Comparing version 0.1.1 to 0.1.2
12
index.js
@@ -62,2 +62,3 @@ var request = require("request"); | ||
* oauth - Options for OAuth HMAC-SHA1 signing, see documentation at https://github.com/mikeal/request#oauth-signing | ||
* stream - A boolean that specifies if the response ust be a stream. | ||
* aws - Object containing aws signing information, should have the properties key and secret as well as bucket | ||
@@ -102,11 +103,10 @@ * unless you're specifying your bucket as part of the path, or you are making a request that doesn't use a bucket | ||
request(optionsToUse, function(error, response) { | ||
var result = null; | ||
if (response) { | ||
result = { | ||
if (options.stream) return cb(error, response); | ||
cb(error, response ? { | ||
status: response.statusCode, | ||
headers: response.headers, | ||
body: tryParseBodyAsJson(response) | ||
}; | ||
} | ||
cb(error, result); | ||
} : null ); | ||
}); | ||
@@ -113,0 +113,0 @@ }; |
{ | ||
"name": "restjs-api", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Kidozen's connector to invoke REST services", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var assert = require('assert'); | ||
var http = require('http'); | ||
var Stream = require('stream'); | ||
@@ -83,2 +84,20 @@ describe('Rest connector:', function(){ | ||
it("'stream' option must work", function (done) { | ||
server = http.createServer(function (req, res) { | ||
res.setHeader("x-foo", "bar"); | ||
res.statusCode = 201; | ||
res.end(); | ||
}).listen(9615); | ||
var instance = new Connector(config); | ||
instance.exec({ method:'get', path: '/foo', stream: true}, function(err, result) { | ||
assert.ok(!err); | ||
assert.ok(result instanceof Stream); | ||
assert.equal("bar", result.headers["x-foo"]); | ||
assert.equal(201, result.statusCode); | ||
done(); | ||
}); | ||
}); | ||
describe ("headers", function() { | ||
@@ -85,0 +104,0 @@ it('should use headers from configuration', function (done) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15569
250