superagent
Advanced tools
Comparing version 0.20.0 to 0.21.0
@@ -5,3 +5,3 @@ { | ||
"description": "awesome http requests", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "http", |
@@ -0,1 +1,11 @@ | ||
0.21.0 / 2014-11-11 | ||
================== | ||
* Trim text before parsing json (gjohnson) | ||
* Update tests to express 4 (gaastonsr) | ||
* Prevent double callback when error is thrown (pgn-vole) | ||
* Fix missing clearTimeout (nickdima) | ||
* Update debug (TooTallNate) | ||
0.20.0 / 2014-10-02 | ||
@@ -2,0 +12,0 @@ ================== |
@@ -297,3 +297,5 @@ /** | ||
this.xhr = this.req.xhr; | ||
this.text = this.xhr.responseText; | ||
this.text = this.req.method !='HEAD' | ||
? this.xhr.responseText | ||
: null; | ||
this.setStatusProperties(this.xhr.status); | ||
@@ -454,12 +456,14 @@ this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); | ||
this.on('end', function(){ | ||
var err = null; | ||
var res = null; | ||
try { | ||
var res = new Response(self); | ||
if ('HEAD' == method) res.text = null; | ||
self.callback(null, res); | ||
res = new Response(self); | ||
} catch(e) { | ||
var err = new Error('Parser is unable to parse the response'); | ||
err = new Error('Parser is unable to parse the response'); | ||
err.parse = true; | ||
err.original = e; | ||
self.callback(err); | ||
} | ||
self.callback(err, res); | ||
}); | ||
@@ -811,2 +815,3 @@ } | ||
var fn = this._callback; | ||
this.clearTimeout(); | ||
if (2 == fn.length) return fn(err, res); | ||
@@ -813,0 +818,0 @@ if (err) return this.emit('error', err); |
@@ -8,7 +8,10 @@ | ||
try { | ||
fn(null, JSON.parse(res.text)); | ||
} catch (err) { | ||
fn(err); | ||
var text = res.text && res.text.replace(/^\s*|\s*$/g, ''); | ||
var body = text && JSON.parse(text); | ||
} catch (e) { | ||
var err = e; | ||
} finally { | ||
fn(err, body); | ||
} | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "superagent", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -29,3 +29,3 @@ "scripts": { | ||
"cookiejar": "2.0.1", | ||
"debug": "~2.0.0", | ||
"debug": "2", | ||
"reduce-component": "1.0.1", | ||
@@ -37,7 +37,11 @@ "extend": "~1.2.1", | ||
"devDependencies": { | ||
"zuul": "~1.6.0", | ||
"express": "3.5.0", | ||
"basic-auth-connect": "^1.0.0", | ||
"better-assert": "~1.0.1", | ||
"body-parser": "^1.9.2", | ||
"cookie-parser": "^1.3.3", | ||
"express": "^4.9.8", | ||
"express-session": "^1.9.1", | ||
"mocha": "*", | ||
"should": "3.1.3", | ||
"mocha": "*" | ||
"zuul": "~1.6.0" | ||
}, | ||
@@ -44,0 +48,0 @@ "browser": { |
@@ -693,3 +693,5 @@ ;(function(){ | ||
this.xhr = this.req.xhr; | ||
this.text = this.xhr.responseText; | ||
this.text = this.req.method !='HEAD' | ||
? this.xhr.responseText | ||
: null; | ||
this.setStatusProperties(this.xhr.status); | ||
@@ -850,12 +852,14 @@ this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); | ||
this.on('end', function(){ | ||
var err = null; | ||
var res = null; | ||
try { | ||
var res = new Response(self); | ||
if ('HEAD' == method) res.text = null; | ||
self.callback(null, res); | ||
res = new Response(self); | ||
} catch(e) { | ||
var err = new Error('Parser is unable to parse the response'); | ||
err = new Error('Parser is unable to parse the response'); | ||
err.parse = true; | ||
err.original = e; | ||
self.callback(err); | ||
} | ||
self.callback(err, res); | ||
}); | ||
@@ -1207,2 +1211,3 @@ } | ||
var fn = this._callback; | ||
this.clearTimeout(); | ||
if (2 == fn.length) return fn(err, res); | ||
@@ -1209,0 +1214,0 @@ if (err) return this.emit('error', err); |
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
111247
3916
9
+ Addeddebug@2.6.9(transitive)
+ Addedms@2.0.0(transitive)
- Removeddebug@2.0.0(transitive)
- Removedms@0.6.2(transitive)
Updateddebug@2