superagent
Advanced tools
Comparing version 0.14.8 to 0.14.9
@@ -5,3 +5,3 @@ { | ||
"description": "awesome http requests", | ||
"version": "0.14.8", | ||
"version": "0.14.9", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "http", |
0.14.9 / 2013-06-15 | ||
================== | ||
* add debug()s to the node client | ||
* add .abort() method to node client | ||
0.14.8 / 2013-06-13 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -11,2 +11,3 @@ /*! | ||
var debug = require('debug')('superagent'); | ||
var formidable = require('formidable'); | ||
@@ -427,2 +428,3 @@ var Response = require('./response'); | ||
Request.prototype.clearTimeout = function(){ | ||
debug('clear timeout %s %s', this.method, this.url); | ||
this._timeout = 0; | ||
@@ -434,2 +436,15 @@ clearTimeout(this._timer); | ||
/** | ||
* Abort and clear timeout. | ||
* | ||
* @api public | ||
*/ | ||
Request.prototype.abort = function(){ | ||
debug('abort %s %s', this.method, this.url); | ||
this._aborted = true; | ||
this.clearTimeout(); | ||
this.req.abort(); | ||
}; | ||
/** | ||
* Define the parser to be used for this response. | ||
@@ -457,2 +472,3 @@ * | ||
var url = res.headers.location; | ||
debug('redirect %s -> %s', this.url, url); | ||
@@ -481,2 +497,3 @@ // location | ||
this._redirectList.push(url); | ||
this.clearTimeout(); | ||
this.emit('redirect', res); | ||
@@ -612,2 +629,3 @@ this.set(header); | ||
var timeout = this._timeout; | ||
debug('%s %s', this.method, this.url); | ||
@@ -619,7 +637,7 @@ // store callback | ||
if (timeout && !this._timer) { | ||
debug('timeout %sms %s %s', timeout, this.method, this.url); | ||
this._timer = setTimeout(function(){ | ||
var err = new Error('timeout of ' + timeout + 'ms exceeded'); | ||
err.timeout = timeout; | ||
self._aborted = true; | ||
req.abort(); | ||
self.abort(); | ||
self.callback(err); | ||
@@ -645,2 +663,3 @@ }, timeout); | ||
req.on('response', function(res){ | ||
debug('%s %s %s', res.statusCode, self.method, self.url); | ||
var max = self._maxRedirects; | ||
@@ -712,2 +731,3 @@ var mime = utils.type(res.headers['content-type'] || ''); | ||
if (!buffer) { | ||
debug('unbuffered %s %s', self.method, self.url); | ||
self.res = res; | ||
@@ -723,2 +743,3 @@ var response = new Response(self.req, self.res); | ||
res.on('end', function(){ | ||
debug('end %s %s', self.method, self.url); | ||
// TODO: unless buffering emit earlier to stream | ||
@@ -725,0 +746,0 @@ var response = new Response(self.req, self.res); |
{ | ||
"name": "superagent", | ||
"version": "0.14.8", | ||
"version": "0.14.9", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -25,3 +25,4 @@ "keywords": [ | ||
"methods": "0.0.1", | ||
"cookiejar": "1.3.0" | ||
"cookiejar": "1.3.0", | ||
"debug": "~0.7.2" | ||
}, | ||
@@ -28,0 +29,0 @@ "devDependencies": { |
104474
3552
7
+ Addeddebug@~0.7.2
+ Addeddebug@0.7.4(transitive)