superagent
Advanced tools
Comparing version 3.5.0 to 3.5.1
@@ -206,2 +206,11 @@ | ||
## Retrying requests | ||
When given the `.retry()` method, SuperAgent will automatically retry requests, if they fail in a way that is transient or could be due to a flaky Internet connection. `.retry()` takes an optional argument which is the maximum number of times to retry failed requests; the default is 3 times. | ||
request | ||
.get('http://example.com/search') | ||
.retry(2) | ||
.end(callback); | ||
## Setting Accept | ||
@@ -566,2 +575,19 @@ | ||
## Progress tracking | ||
SuperAgent fires `progress` events on upload and download of large files. | ||
request.post(url) | ||
.attach(file) | ||
.on('progress', event => { | ||
/* the event is: | ||
{ | ||
direction: "upload" or "download" | ||
percent: 0 to 100 // may be missing if file size is unknown | ||
total: // total file size, may be missing | ||
loaded: // bytes downloaded or uploaded so far | ||
} */ | ||
}) | ||
.end() | ||
## Promise and Generator support | ||
@@ -568,0 +594,0 @@ |
@@ -0,1 +1,7 @@ | ||
# 3.5.1 (2017-03-18) | ||
* Allow crossDomain errors to be retried (#1194) (Michael Olson) | ||
* Read responseType property from the correct object (Julien Dupouy) | ||
* Check for ownProperty before adding header (Lucas Vieira) | ||
# 3.5.0 (2017-02-23) | ||
@@ -2,0 +8,0 @@ |
@@ -788,3 +788,5 @@ /** | ||
if (null == this.header[field]) continue; | ||
xhr.setRequestHeader(field, this.header[field]); | ||
if (this.header.hasOwnProperty(field)) | ||
xhr.setRequestHeader(field, this.header[field]); | ||
} | ||
@@ -791,0 +793,0 @@ |
@@ -632,3 +632,4 @@ | ||
for (var key in this.header) { | ||
req.setHeader(key, this.header[key]); | ||
if (this.header.hasOwnProperty(key)) | ||
req.setHeader(key, this.header[key]); | ||
} | ||
@@ -811,2 +812,3 @@ | ||
var parser = self._parser; | ||
var responseType = self._responseType; | ||
@@ -832,3 +834,3 @@ self.res = res; | ||
if (!parser) { | ||
if (this._responseType) { | ||
if (responseType) { | ||
parser = exports.parse.image; // It's actually a generic Buffer | ||
@@ -835,0 +837,0 @@ buffer = true; |
@@ -21,3 +21,4 @@ var ERROR_CODES = [ | ||
if (err && 'timeout' in err && err.code == 'ECONNABORTED') return true; | ||
if (err && 'crossDomain' in err) return true; | ||
return false; | ||
}; | ||
}; |
{ | ||
"name": "superagent", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -782,4 +782,6 @@ (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){ | ||
if (err && 'timeout' in err && err.code == 'ECONNABORTED') return true; | ||
if (err && 'crossDomain' in err) return true; | ||
return false; | ||
}; | ||
},{}],6:[function(require,module,exports){ | ||
@@ -1807,3 +1809,5 @@ | ||
if (null == this.header[field]) continue; | ||
xhr.setRequestHeader(field, this.header[field]); | ||
if (this.header.hasOwnProperty(field)) | ||
xhr.setRequestHeader(field, this.header[field]); | ||
} | ||
@@ -1810,0 +1814,0 @@ |
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
246537
4501