superagent
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
@@ -459,1 +459,6 @@ | ||
Note that superagent expects the global `Promise` object to be present. You'll need a polyfill to use promises in Internet Explorer or Node.js 0.10. | ||
## Using browser version in electron | ||
[Electron](http://electron.atom.io/) developers report if you would prefer to use the browser version of superagent instead of the node version, you can `require('superagent/superagent')`. Your requests will now show up in the chrome developer tools network tab. Note this environment is not covered by automated test suite and not officially supported. |
@@ -504,12 +504,16 @@ /** | ||
if (res.status >= 200 && res.status < 300) { | ||
return self.callback(err, res); | ||
} | ||
try { | ||
if (res.status >= 200 && res.status < 300) { | ||
return self.callback(err, res); | ||
} | ||
var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); | ||
new_err.original = err; | ||
new_err.response = res; | ||
new_err.status = res.status; | ||
var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); | ||
new_err.original = err; | ||
new_err.response = res; | ||
new_err.status = res.status; | ||
self.callback(new_err, res); | ||
self.callback(new_err, res); | ||
} catch(e) { | ||
self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android | ||
} | ||
}); | ||
@@ -516,0 +520,0 @@ } |
@@ -354,2 +354,9 @@ | ||
self.res = res; | ||
var response = new Response(self); | ||
self.response = response; | ||
self.emit('response', response); | ||
response.redirects = self._redirectList; | ||
if (self._aborted) return; | ||
if (self._shouldUnzip(res)) { | ||
@@ -681,2 +688,7 @@ res.pipe(zlib.createUnzip()).pipe(stream, options); | ||
debug('%s %s -> %s', self.method, self.url, res.statusCode); | ||
if (self.piped) { | ||
return; | ||
} | ||
var max = self._maxRedirects; | ||
@@ -694,6 +706,2 @@ var mime = utils.type(res.headers['content-type'] || '') || 'text/plain'; | ||
if (self.piped) { | ||
return; | ||
} | ||
// redirect | ||
@@ -700,0 +708,0 @@ if (redirect && self._redirects++ != max) { |
{ | ||
"name": "superagent", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -404,3 +404,5 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
module.exports = Emitter; | ||
if (typeof module !== 'undefined') { | ||
module.exports = Emitter; | ||
} | ||
@@ -1091,12 +1093,16 @@ /** | ||
if (res.status >= 200 && res.status < 300) { | ||
return self.callback(err, res); | ||
} | ||
try { | ||
if (res.status >= 200 && res.status < 300) { | ||
return self.callback(err, res); | ||
} | ||
var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); | ||
new_err.original = err; | ||
new_err.response = res; | ||
new_err.status = res.status; | ||
var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); | ||
new_err.original = err; | ||
new_err.response = res; | ||
new_err.status = res.status; | ||
self.callback(new_err, res); | ||
self.callback(new_err, res); | ||
} catch(e) { | ||
self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android | ||
} | ||
}); | ||
@@ -1103,0 +1109,0 @@ } |
Sorry, the diff of this file is not supported yet
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
326122
4299
35