Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restify

Package Overview
Dependencies
Maintainers
0
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify - npm Package Compare versions

Comparing version 0.1.20 to 0.1.21

52

lib/client.js

@@ -56,3 +56,5 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.

if (!(!options.url !== !options.socketPath)) // JS XOR...
// Stupid JS not having an XOR, and jslint hating the tricky way...
if (!(options.url || options.socketPath) ||
(options.url && options.socketPath))
throw new TypeError('One of options.url, options.socketPath are required');

@@ -63,3 +65,4 @@

this.proto = http;
if (this.url.protocol === 'https:') this.proto = https;
if (this.url.protocol === 'https:')
this.proto = https;
}

@@ -72,6 +75,17 @@ if (options.socketPath) {

this.path = options.path || url.pathname || '/';
// https://github.com/joyent/node/issues/711 introduced a bug, IMO,
// where `pathname=="/"` even for, e.g., "http://example.com". Ignore
// the '/' in that case.
this.path = options.path || '';
if (!this.path &&
this.url &&
!(this.url.pathname === '/' &&
options.url[options.url.length-1] !== '/')) {
this.path = this.url.pathname;
}
this.headers = {
Accept: 'application/json'
};
if (options.version)

@@ -117,3 +131,2 @@ this.headers['x-api-version'] = options.version;

RestClient.prototype.put = function(options, callback) {
log.trace('RestClient.put options=%o', options);
var args = this._processArguments([200, 201], 'PUT', options, callback);

@@ -137,3 +150,3 @@ var opts = args.options;

return callback(null, obj, headers);
return cb(null, obj, headers);
});

@@ -174,3 +187,3 @@ };

return callback(null, obj, headers);
return cb(null, obj, headers);
});

@@ -210,3 +223,3 @@ };

return callback(null, obj, headers, res);
return cb(null, obj, headers, res);
});

@@ -247,3 +260,3 @@ };

return callback(null, headers);
return cb(null, headers);
});

@@ -283,3 +296,3 @@ };

return callback(null, headers);
return cb(null, headers);
});

@@ -315,3 +328,3 @@ };

var operation = retry.operation(self.retryOptions);
operation.try(function(attempt) {
operation.start(function(attempt) {
options.headers.Date = utils.newHttpDate(new Date());

@@ -355,3 +368,3 @@ log.trace('RestClient(attempt=%d): issuing request %o', attempt, options);

message: 'Content-Length ' + len + ' didn\'t match: ' +
res.body.length,
res.body.length
}));

@@ -440,3 +453,3 @@ }

opts.host = self.url.hostname.toString();
opts.port = self.url.port.toString();
opts.port = (self.url.port || 80).toString();
} else {

@@ -455,15 +468,22 @@ opts.socketPath = self.socketPath.toString();

var opts = this._newHttpOptions(method);
if (options) {
if (typeof(options) === 'function') {
callback = options;
} else {
} else if (typeof(options) === 'string') {
opts.path = options;
} else if (typeof(options) === 'object') {
var headers = opts.headers;
var path = opts.path + options.path;
utils.extend(options, opts);
opts.path = path;
opts.headers = headers;
if (options.headers) {
if (options.headers)
utils.extend(options.headers, opts.headers);
}
} else {
throw new TypeError('options is an invalid type: ' + typeof(options));
}
}
if (callback && typeof(callback) !== 'function')
if (!callback || typeof(callback) !== 'function')
throw new TypeError('callback must be a function');

@@ -470,0 +490,0 @@

{
"name": "restify",
"description": "REST framework specifically meant for web service APIs",
"version": "0.1.20",
"version": "0.1.21",
"repository": {

@@ -14,6 +14,6 @@ "type": "git",

"node-uuid": ">=1.1.0",
"retry": ">=0.2.0"
"retry": ">=0.3.0"
},
"scripts": {
"pretest": "./node_modules/.bin/jshint tst",
"pretest": "./node_modules/.bin/jshint lib tst",
"test": "./node_modules/.bin/whiskey --timeout 2000 -t \"`find tst -name *.test.js | xargs`\""

@@ -20,0 +20,0 @@ },

@@ -290,2 +290,47 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.

exports.test_head_string = function(test, assert) {
client.head('/test/foo?code=204', function(err, headers) {
assert.ifError(err);
assert.ok(headers);
test.finish();
});
};
exports.test_get_string = function(test, assert) {
client.get('/test/foo', function(err, headers) {
assert.ifError(err);
assert.ok(headers);
test.finish();
});
};
exports.test_put_string = function(test, assert) {
client.put('/test/foo', function(err, headers) {
assert.ifError(err);
assert.ok(headers);
test.finish();
});
};
exports.test_post_string = function(test, assert) {
client.post('/test/foo', function(err, headers) {
assert.ifError(err);
assert.ok(headers);
test.finish();
});
};
exports.test_del_string = function(test, assert) {
client.del('/test/foo', function(err, headers) {
assert.ifError(err);
assert.ok(headers);
test.finish();
});
};
exports.tearDown = function(test, assert) {

@@ -292,0 +337,0 @@ server.on('close', function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc