Comparing version 0.3.14 to 0.3.15
@@ -52,4 +52,11 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
function RestClient(options) { | ||
if (!options) throw new TypeError('options is required'); | ||
if (!options) | ||
throw new TypeError('options is required'); | ||
// Sigh - this is a hack to enable a large project setting the verbosity | ||
// of the client to something higher than the default trace without turning | ||
// up everything (This is useful so you don't have to run wireshark...). | ||
// This is *not* documented! | ||
this._log = options._log || log.trace; | ||
// Stupid JS not having an XOR, and jslint hating the tricky way... | ||
@@ -316,2 +323,4 @@ if (!(options.url || options.socketPath) || | ||
var _id = uuid().replace(/-/, '').substr(0, 7); // logging only | ||
var self = this; | ||
@@ -357,7 +366,8 @@ | ||
log.trace('RestClient(attempt=%d): issuing request %o', attempt, options); | ||
self._log.call(log, 'RestClient(%s, attempt=%d): issuing request %o', | ||
_id, attempt, options); | ||
var req = self.proto.request(options, function(res) { | ||
log.trace('RestClient: %s %s => code=%d, headers=%o', | ||
options.method, options.path, res.statusCode, res.headers); | ||
self._log.call(log, 'RestClient(%s): %s %s => code=%d, headers=%o', _id, | ||
options.method, options.path, res.statusCode, res.headers); | ||
@@ -369,4 +379,4 @@ var err = null; | ||
function endResponse() { | ||
log.trace('RestClient: %s %s => body=%s', | ||
options.method, options.path, res.body); | ||
self._log.call(log, 'RestClient(%s): %s %s => body=%s', _id, | ||
options.method, options.path, res.body); | ||
@@ -373,0 +383,0 @@ if (self.retryCallback(res.statusCode)) { |
@@ -82,3 +82,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
data = JSON.stringify(_opts.body); | ||
data = data + '\n'; | ||
//data = data + '\n'; | ||
} else if (this._config.contentWriters[this._accept]) { | ||
@@ -107,2 +107,3 @@ data = this._config.contentWriters[this._accept](_opts.body); | ||
} | ||
this.__headers = headers; | ||
@@ -112,10 +113,12 @@ log.trace('response.send: code=%d, headers=%o, body=%s', | ||
this.writeHead(_opts.code, headers); | ||
if (_opts.code !== HttpCodes.NoContent && this._method !== 'HEAD' && data) | ||
this.write(data); | ||
if (!this._sent) { | ||
this.writeHead(_opts.code, headers); | ||
if (_opts.code !== HttpCodes.NoContent && this._method !== 'HEAD' && data) | ||
this.write(data); | ||
if (!_opts.noEnd) { | ||
this.end(); | ||
this.responseSent = true; | ||
this._sent = true; | ||
this.emit('responseSent'); | ||
if (!_opts.noEnd) | ||
this.end(); | ||
} | ||
@@ -146,3 +149,3 @@ }; | ||
this.send(error.httpCode, _e, error.headers); | ||
this.errorSent = true; | ||
this._errorSent = true; | ||
this.emit('errorSent'); | ||
@@ -149,0 +152,0 @@ |
@@ -511,3 +511,17 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
response._config = server._config; | ||
response._sent = false; | ||
response._errorSent = false; | ||
// HTTP and HTTPS are different -> joyent/node GH #1005 | ||
var addr = request.connection.remoteAddress; | ||
if (!addr) { | ||
if (request.connection.socket) { | ||
addr = request.connection.socket.remoteAddress; | ||
} else { | ||
addr = 'unknown'; | ||
} | ||
} | ||
request._remoteAddress = addr; | ||
response._remoteAddress = addr; | ||
if (!_parseHead(request, response)) | ||
@@ -572,4 +586,4 @@ return log.w3cLog(request, response, function() {}); | ||
// Check if we need to skip to the post chain | ||
if ((stage === 0 && response.responseSent) || | ||
(stage === 1 && response.errorSent)) { | ||
if ((stage === 0 && response._sent) || | ||
(stage === 1 && response._errorSent)) { | ||
stage = 2; | ||
@@ -576,0 +590,0 @@ handler = 0; |
{ | ||
"name": "restify", | ||
"description": "REST framework specifically meant for web service APIs", | ||
"version": "0.3.14", | ||
"version": "0.3.15", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -104,3 +104,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
opts.method = 'GET'; | ||
opts.headers.authorization = 'Basic ' + uuid(); | ||
opts.headers.authorization = 'Basic ImNotValidBase64'; | ||
@@ -107,0 +107,0 @@ http.request(opts, function(res) { |
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
221804
4179