comprodls-sdk 2.54.0 → 2.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comprodls-sdk.js +879 -683
- package/dist/comprodls-sdk.min.js +16 -16
- package/lib/services/analytics/index.js +5 -5
- package/package.json +1 -1
package/dist/comprodls-sdk.js
CHANGED
|
@@ -1137,7 +1137,7 @@ validator.validators.contains = function(value, options) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
1139
|
};
|
|
1140
|
-
},{"./errors":7,"validate.js":
|
|
1140
|
+
},{"./errors":7,"validate.js":96}],10:[function(require,module,exports){
|
|
1141
1141
|
/*************************************************************************
|
|
1142
1142
|
*
|
|
1143
1143
|
* COMPRO CONFIDENTIAL
|
|
@@ -2840,7 +2840,8 @@ function getClassProductRecentPendingSubmissions(options) {
|
|
|
2840
2840
|
|
|
2841
2841
|
/*options = {
|
|
2842
2842
|
* classid: 'string', // class uuid
|
|
2843
|
-
* productcode: 'string',
|
|
2843
|
+
* productcode: 'string', // product code
|
|
2844
|
+
* userids: 'string', // comma separated userids as a single string e.g. '<userid1>,<userid2>..'(optional)
|
|
2844
2845
|
* includeContext: 'boolean' // includse context or heirarchy (optional)
|
|
2845
2846
|
*}
|
|
2846
2847
|
*/
|
|
@@ -2863,8 +2864,9 @@ function getClassRecord(options) {
|
|
|
2863
2864
|
var queryParams = {
|
|
2864
2865
|
classid: options.classid,
|
|
2865
2866
|
productcode: options.productcode,
|
|
2867
|
+
userids: options.userids,
|
|
2866
2868
|
includeContext: options.includeContext
|
|
2867
|
-
}
|
|
2869
|
+
};
|
|
2868
2870
|
|
|
2869
2871
|
// Setup Request with url and params
|
|
2870
2872
|
var requestAPI = request.get(url).query(queryParams);
|
|
@@ -2879,9 +2881,7 @@ function getClassRecord(options) {
|
|
|
2879
2881
|
if(error) {
|
|
2880
2882
|
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
2881
2883
|
dfd.reject(err);
|
|
2882
|
-
} else {
|
|
2883
|
-
dfd.resolve(response.body)
|
|
2884
|
-
}
|
|
2884
|
+
} else { dfd.resolve(response.body); }
|
|
2885
2885
|
});
|
|
2886
2886
|
}
|
|
2887
2887
|
} else {
|
|
@@ -11406,7 +11406,7 @@ function createStatement(options) {
|
|
|
11406
11406
|
}*/
|
|
11407
11407
|
|
|
11408
11408
|
|
|
11409
|
-
},{"../../helpers":3,"q":59,"tincanjs":
|
|
11409
|
+
},{"../../helpers":3,"q":59,"tincanjs":93}],24:[function(require,module,exports){
|
|
11410
11410
|
/*************************************************************************
|
|
11411
11411
|
*
|
|
11412
11412
|
* COMPRO CONFIDENTIAL
|
|
@@ -17818,167 +17818,181 @@ module.exports = {
|
|
|
17818
17818
|
}
|
|
17819
17819
|
|
|
17820
17820
|
},{}],43:[function(require,module,exports){
|
|
17821
|
-
|
|
17822
|
-
/**
|
|
17823
|
-
* Expose `Emitter`.
|
|
17824
|
-
*/
|
|
17825
|
-
|
|
17826
|
-
module
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
*
|
|
17832
|
-
|
|
17833
|
-
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
17840
|
-
|
|
17841
|
-
*
|
|
17842
|
-
*
|
|
17843
|
-
* @
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
}
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
*
|
|
17857
|
-
*
|
|
17858
|
-
* @
|
|
17859
|
-
* @
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
*
|
|
17874
|
-
*
|
|
17875
|
-
*
|
|
17876
|
-
* @
|
|
17877
|
-
* @
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
*
|
|
17895
|
-
*
|
|
17896
|
-
*
|
|
17897
|
-
* @
|
|
17898
|
-
* @
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
Emitter.prototype.
|
|
17904
|
-
Emitter.prototype.
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
}
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
}
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
*
|
|
17974
|
-
*
|
|
17975
|
-
* @
|
|
17976
|
-
* @
|
|
17977
|
-
|
|
17978
|
-
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
};
|
|
17821
|
+
|
|
17822
|
+
/**
|
|
17823
|
+
* Expose `Emitter`.
|
|
17824
|
+
*/
|
|
17825
|
+
|
|
17826
|
+
if (typeof module !== 'undefined') {
|
|
17827
|
+
module.exports = Emitter;
|
|
17828
|
+
}
|
|
17829
|
+
|
|
17830
|
+
/**
|
|
17831
|
+
* Initialize a new `Emitter`.
|
|
17832
|
+
*
|
|
17833
|
+
* @api public
|
|
17834
|
+
*/
|
|
17835
|
+
|
|
17836
|
+
function Emitter(obj) {
|
|
17837
|
+
if (obj) return mixin(obj);
|
|
17838
|
+
};
|
|
17839
|
+
|
|
17840
|
+
/**
|
|
17841
|
+
* Mixin the emitter properties.
|
|
17842
|
+
*
|
|
17843
|
+
* @param {Object} obj
|
|
17844
|
+
* @return {Object}
|
|
17845
|
+
* @api private
|
|
17846
|
+
*/
|
|
17847
|
+
|
|
17848
|
+
function mixin(obj) {
|
|
17849
|
+
for (var key in Emitter.prototype) {
|
|
17850
|
+
obj[key] = Emitter.prototype[key];
|
|
17851
|
+
}
|
|
17852
|
+
return obj;
|
|
17853
|
+
}
|
|
17854
|
+
|
|
17855
|
+
/**
|
|
17856
|
+
* Listen on the given `event` with `fn`.
|
|
17857
|
+
*
|
|
17858
|
+
* @param {String} event
|
|
17859
|
+
* @param {Function} fn
|
|
17860
|
+
* @return {Emitter}
|
|
17861
|
+
* @api public
|
|
17862
|
+
*/
|
|
17863
|
+
|
|
17864
|
+
Emitter.prototype.on =
|
|
17865
|
+
Emitter.prototype.addEventListener = function(event, fn){
|
|
17866
|
+
this._callbacks = this._callbacks || {};
|
|
17867
|
+
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
|
|
17868
|
+
.push(fn);
|
|
17869
|
+
return this;
|
|
17870
|
+
};
|
|
17871
|
+
|
|
17872
|
+
/**
|
|
17873
|
+
* Adds an `event` listener that will be invoked a single
|
|
17874
|
+
* time then automatically removed.
|
|
17875
|
+
*
|
|
17876
|
+
* @param {String} event
|
|
17877
|
+
* @param {Function} fn
|
|
17878
|
+
* @return {Emitter}
|
|
17879
|
+
* @api public
|
|
17880
|
+
*/
|
|
17881
|
+
|
|
17882
|
+
Emitter.prototype.once = function(event, fn){
|
|
17883
|
+
function on() {
|
|
17884
|
+
this.off(event, on);
|
|
17885
|
+
fn.apply(this, arguments);
|
|
17886
|
+
}
|
|
17887
|
+
|
|
17888
|
+
on.fn = fn;
|
|
17889
|
+
this.on(event, on);
|
|
17890
|
+
return this;
|
|
17891
|
+
};
|
|
17892
|
+
|
|
17893
|
+
/**
|
|
17894
|
+
* Remove the given callback for `event` or all
|
|
17895
|
+
* registered callbacks.
|
|
17896
|
+
*
|
|
17897
|
+
* @param {String} event
|
|
17898
|
+
* @param {Function} fn
|
|
17899
|
+
* @return {Emitter}
|
|
17900
|
+
* @api public
|
|
17901
|
+
*/
|
|
17902
|
+
|
|
17903
|
+
Emitter.prototype.off =
|
|
17904
|
+
Emitter.prototype.removeListener =
|
|
17905
|
+
Emitter.prototype.removeAllListeners =
|
|
17906
|
+
Emitter.prototype.removeEventListener = function(event, fn){
|
|
17907
|
+
this._callbacks = this._callbacks || {};
|
|
17908
|
+
|
|
17909
|
+
// all
|
|
17910
|
+
if (0 == arguments.length) {
|
|
17911
|
+
this._callbacks = {};
|
|
17912
|
+
return this;
|
|
17913
|
+
}
|
|
17914
|
+
|
|
17915
|
+
// specific event
|
|
17916
|
+
var callbacks = this._callbacks['$' + event];
|
|
17917
|
+
if (!callbacks) return this;
|
|
17918
|
+
|
|
17919
|
+
// remove all handlers
|
|
17920
|
+
if (1 == arguments.length) {
|
|
17921
|
+
delete this._callbacks['$' + event];
|
|
17922
|
+
return this;
|
|
17923
|
+
}
|
|
17924
|
+
|
|
17925
|
+
// remove specific handler
|
|
17926
|
+
var cb;
|
|
17927
|
+
for (var i = 0; i < callbacks.length; i++) {
|
|
17928
|
+
cb = callbacks[i];
|
|
17929
|
+
if (cb === fn || cb.fn === fn) {
|
|
17930
|
+
callbacks.splice(i, 1);
|
|
17931
|
+
break;
|
|
17932
|
+
}
|
|
17933
|
+
}
|
|
17934
|
+
|
|
17935
|
+
// Remove event specific arrays for event types that no
|
|
17936
|
+
// one is subscribed for to avoid memory leak.
|
|
17937
|
+
if (callbacks.length === 0) {
|
|
17938
|
+
delete this._callbacks['$' + event];
|
|
17939
|
+
}
|
|
17940
|
+
|
|
17941
|
+
return this;
|
|
17942
|
+
};
|
|
17943
|
+
|
|
17944
|
+
/**
|
|
17945
|
+
* Emit `event` with the given args.
|
|
17946
|
+
*
|
|
17947
|
+
* @param {String} event
|
|
17948
|
+
* @param {Mixed} ...
|
|
17949
|
+
* @return {Emitter}
|
|
17950
|
+
*/
|
|
17951
|
+
|
|
17952
|
+
Emitter.prototype.emit = function(event){
|
|
17953
|
+
this._callbacks = this._callbacks || {};
|
|
17954
|
+
|
|
17955
|
+
var args = new Array(arguments.length - 1)
|
|
17956
|
+
, callbacks = this._callbacks['$' + event];
|
|
17957
|
+
|
|
17958
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17959
|
+
args[i - 1] = arguments[i];
|
|
17960
|
+
}
|
|
17961
|
+
|
|
17962
|
+
if (callbacks) {
|
|
17963
|
+
callbacks = callbacks.slice(0);
|
|
17964
|
+
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
|
17965
|
+
callbacks[i].apply(this, args);
|
|
17966
|
+
}
|
|
17967
|
+
}
|
|
17968
|
+
|
|
17969
|
+
return this;
|
|
17970
|
+
};
|
|
17971
|
+
|
|
17972
|
+
/**
|
|
17973
|
+
* Return array of callbacks for `event`.
|
|
17974
|
+
*
|
|
17975
|
+
* @param {String} event
|
|
17976
|
+
* @return {Array}
|
|
17977
|
+
* @api public
|
|
17978
|
+
*/
|
|
17979
|
+
|
|
17980
|
+
Emitter.prototype.listeners = function(event){
|
|
17981
|
+
this._callbacks = this._callbacks || {};
|
|
17982
|
+
return this._callbacks['$' + event] || [];
|
|
17983
|
+
};
|
|
17984
|
+
|
|
17985
|
+
/**
|
|
17986
|
+
* Check if this emitter has `event` handlers.
|
|
17987
|
+
*
|
|
17988
|
+
* @param {String} event
|
|
17989
|
+
* @return {Boolean}
|
|
17990
|
+
* @api public
|
|
17991
|
+
*/
|
|
17992
|
+
|
|
17993
|
+
Emitter.prototype.hasListeners = function(event){
|
|
17994
|
+
return !! this.listeners(event).length;
|
|
17995
|
+
};
|
|
17982
17996
|
|
|
17983
17997
|
},{}],44:[function(require,module,exports){
|
|
17984
17998
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
@@ -18393,6 +18407,8 @@ function isUndefined(arg) {
|
|
|
18393
18407
|
}
|
|
18394
18408
|
|
|
18395
18409
|
},{}],46:[function(require,module,exports){
|
|
18410
|
+
'use strict';
|
|
18411
|
+
|
|
18396
18412
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
18397
18413
|
var toStr = Object.prototype.toString;
|
|
18398
18414
|
var defineProperty = Object.defineProperty;
|
|
@@ -18407,8 +18423,6 @@ var isArray = function isArray(arr) {
|
|
|
18407
18423
|
};
|
|
18408
18424
|
|
|
18409
18425
|
var isPlainObject = function isPlainObject(obj) {
|
|
18410
|
-
'use strict';
|
|
18411
|
-
|
|
18412
18426
|
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
18413
18427
|
return false;
|
|
18414
18428
|
}
|
|
@@ -18458,8 +18472,6 @@ var getProperty = function getProperty(obj, name) {
|
|
|
18458
18472
|
};
|
|
18459
18473
|
|
|
18460
18474
|
module.exports = function extend() {
|
|
18461
|
-
'use strict';
|
|
18462
|
-
|
|
18463
18475
|
var options, name, src, copy, copyIsArray, clone;
|
|
18464
18476
|
var target = arguments[0];
|
|
18465
18477
|
var i = 1;
|
|
@@ -24007,7 +24019,7 @@ Writable.prototype._destroy = function (err, cb) {
|
|
|
24007
24019
|
cb(err);
|
|
24008
24020
|
};
|
|
24009
24021
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
24010
|
-
},{"./_stream_duplex":64,"./internal/streams/destroy":70,"./internal/streams/stream":71,"_process":56,"core-util-is":44,"inherits":72,"process-nextick-args":55,"safe-buffer":74,"util-deprecate":
|
|
24022
|
+
},{"./_stream_duplex":64,"./internal/streams/destroy":70,"./internal/streams/stream":71,"_process":56,"core-util-is":44,"inherits":72,"process-nextick-args":55,"safe-buffer":74,"util-deprecate":95}],69:[function(require,module,exports){
|
|
24011
24023
|
'use strict';
|
|
24012
24024
|
|
|
24013
24025
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -24815,7 +24827,7 @@ http.METHODS = [
|
|
|
24815
24827
|
'UNLOCK',
|
|
24816
24828
|
'UNSUBSCRIBE'
|
|
24817
24829
|
]
|
|
24818
|
-
},{"./lib/request":85,"builtin-status-codes":42,"url":
|
|
24830
|
+
},{"./lib/request":85,"builtin-status-codes":42,"url":94,"xtend":98}],84:[function(require,module,exports){
|
|
24819
24831
|
(function (global){
|
|
24820
24832
|
exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableByteStream)
|
|
24821
24833
|
|
|
@@ -25365,6 +25377,8 @@ function template(string) {
|
|
|
25365
25377
|
|
|
25366
25378
|
var Emitter = require('emitter');
|
|
25367
25379
|
var reduce = require('reduce');
|
|
25380
|
+
var requestBase = require('./request-base');
|
|
25381
|
+
var isObject = require('./is-object');
|
|
25368
25382
|
|
|
25369
25383
|
/**
|
|
25370
25384
|
* Root reference for iframes.
|
|
@@ -25386,28 +25400,10 @@ if (typeof window !== 'undefined') { // Browser window
|
|
|
25386
25400
|
function noop(){};
|
|
25387
25401
|
|
|
25388
25402
|
/**
|
|
25389
|
-
*
|
|
25390
|
-
* we don't want to serialize these :)
|
|
25391
|
-
*
|
|
25392
|
-
* TODO: future proof, move to compoent land
|
|
25393
|
-
*
|
|
25394
|
-
* @param {Object} obj
|
|
25395
|
-
* @return {Boolean}
|
|
25396
|
-
* @api private
|
|
25403
|
+
* Expose `request`.
|
|
25397
25404
|
*/
|
|
25398
25405
|
|
|
25399
|
-
|
|
25400
|
-
var str = {}.toString.call(obj);
|
|
25401
|
-
|
|
25402
|
-
switch (str) {
|
|
25403
|
-
case '[object File]':
|
|
25404
|
-
case '[object Blob]':
|
|
25405
|
-
case '[object FormData]':
|
|
25406
|
-
return true;
|
|
25407
|
-
default:
|
|
25408
|
-
return false;
|
|
25409
|
-
}
|
|
25410
|
-
}
|
|
25406
|
+
var request = module.exports = require('./request').bind(null, Request);
|
|
25411
25407
|
|
|
25412
25408
|
/**
|
|
25413
25409
|
* Determine XHR.
|
|
@@ -25439,18 +25435,6 @@ var trim = ''.trim
|
|
|
25439
25435
|
? function(s) { return s.trim(); }
|
|
25440
25436
|
: function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
|
|
25441
25437
|
|
|
25442
|
-
/**
|
|
25443
|
-
* Check if `obj` is an object.
|
|
25444
|
-
*
|
|
25445
|
-
* @param {Object} obj
|
|
25446
|
-
* @return {Boolean}
|
|
25447
|
-
* @api private
|
|
25448
|
-
*/
|
|
25449
|
-
|
|
25450
|
-
function isObject(obj) {
|
|
25451
|
-
return obj === Object(obj);
|
|
25452
|
-
}
|
|
25453
|
-
|
|
25454
25438
|
/**
|
|
25455
25439
|
* Serialize the given `obj`.
|
|
25456
25440
|
*
|
|
@@ -25465,8 +25449,8 @@ function serialize(obj) {
|
|
|
25465
25449
|
for (var key in obj) {
|
|
25466
25450
|
if (null != obj[key]) {
|
|
25467
25451
|
pushEncodedKeyValuePair(pairs, key, obj[key]);
|
|
25468
|
-
|
|
25469
|
-
|
|
25452
|
+
}
|
|
25453
|
+
}
|
|
25470
25454
|
return pairs.join('&');
|
|
25471
25455
|
}
|
|
25472
25456
|
|
|
@@ -25484,6 +25468,11 @@ function pushEncodedKeyValuePair(pairs, key, val) {
|
|
|
25484
25468
|
return val.forEach(function(v) {
|
|
25485
25469
|
pushEncodedKeyValuePair(pairs, key, v);
|
|
25486
25470
|
});
|
|
25471
|
+
} else if (isObject(val)) {
|
|
25472
|
+
for(var subkey in val) {
|
|
25473
|
+
pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
|
|
25474
|
+
}
|
|
25475
|
+
return;
|
|
25487
25476
|
}
|
|
25488
25477
|
pairs.push(encodeURIComponent(key)
|
|
25489
25478
|
+ '=' + encodeURIComponent(val));
|
|
@@ -25506,13 +25495,18 @@ function pushEncodedKeyValuePair(pairs, key, val) {
|
|
|
25506
25495
|
function parseString(str) {
|
|
25507
25496
|
var obj = {};
|
|
25508
25497
|
var pairs = str.split('&');
|
|
25509
|
-
var parts;
|
|
25510
25498
|
var pair;
|
|
25499
|
+
var pos;
|
|
25511
25500
|
|
|
25512
25501
|
for (var i = 0, len = pairs.length; i < len; ++i) {
|
|
25513
25502
|
pair = pairs[i];
|
|
25514
|
-
|
|
25515
|
-
|
|
25503
|
+
pos = pair.indexOf('=');
|
|
25504
|
+
if (pos == -1) {
|
|
25505
|
+
obj[decodeURIComponent(pair)] = '';
|
|
25506
|
+
} else {
|
|
25507
|
+
obj[decodeURIComponent(pair.slice(0, pos))] =
|
|
25508
|
+
decodeURIComponent(pair.slice(pos + 1));
|
|
25509
|
+
}
|
|
25516
25510
|
}
|
|
25517
25511
|
|
|
25518
25512
|
return obj;
|
|
@@ -25696,15 +25690,15 @@ function Response(req, options) {
|
|
|
25696
25690
|
? this.xhr.responseText
|
|
25697
25691
|
: null;
|
|
25698
25692
|
this.statusText = this.req.xhr.statusText;
|
|
25699
|
-
this.
|
|
25693
|
+
this._setStatusProperties(this.xhr.status);
|
|
25700
25694
|
this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
|
|
25701
25695
|
// getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
|
|
25702
25696
|
// getResponseHeader still works. so we get content-type even if getting
|
|
25703
25697
|
// other headers fails.
|
|
25704
25698
|
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
|
|
25705
|
-
this.
|
|
25699
|
+
this._setHeaderProperties(this.header);
|
|
25706
25700
|
this.body = this.req.method != 'HEAD'
|
|
25707
|
-
? this.
|
|
25701
|
+
? this._parseBody(this.text ? this.text : this.xhr.response)
|
|
25708
25702
|
: null;
|
|
25709
25703
|
}
|
|
25710
25704
|
|
|
@@ -25732,7 +25726,7 @@ Response.prototype.get = function(field){
|
|
|
25732
25726
|
* @api private
|
|
25733
25727
|
*/
|
|
25734
25728
|
|
|
25735
|
-
Response.prototype.
|
|
25729
|
+
Response.prototype._setHeaderProperties = function(header){
|
|
25736
25730
|
// content-type
|
|
25737
25731
|
var ct = this.header['content-type'] || '';
|
|
25738
25732
|
this.type = type(ct);
|
|
@@ -25753,8 +25747,11 @@ Response.prototype.setHeaderProperties = function(header){
|
|
|
25753
25747
|
* @api private
|
|
25754
25748
|
*/
|
|
25755
25749
|
|
|
25756
|
-
Response.prototype.
|
|
25750
|
+
Response.prototype._parseBody = function(str){
|
|
25757
25751
|
var parse = request.parse[this.type];
|
|
25752
|
+
if (!parse && isJSON(this.type)) {
|
|
25753
|
+
parse = request.parse['application/json'];
|
|
25754
|
+
}
|
|
25758
25755
|
return parse && str && (str.length || str instanceof Object)
|
|
25759
25756
|
? parse(str)
|
|
25760
25757
|
: null;
|
|
@@ -25781,7 +25778,7 @@ Response.prototype.parseBody = function(str){
|
|
|
25781
25778
|
* @api private
|
|
25782
25779
|
*/
|
|
25783
25780
|
|
|
25784
|
-
Response.prototype.
|
|
25781
|
+
Response.prototype._setStatusProperties = function(status){
|
|
25785
25782
|
// handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
|
|
25786
25783
|
if (status === 1223) {
|
|
25787
25784
|
status = 204;
|
|
@@ -25849,12 +25846,11 @@ request.Response = Response;
|
|
|
25849
25846
|
|
|
25850
25847
|
function Request(method, url) {
|
|
25851
25848
|
var self = this;
|
|
25852
|
-
Emitter.call(this);
|
|
25853
25849
|
this._query = this._query || [];
|
|
25854
25850
|
this.method = method;
|
|
25855
25851
|
this.url = url;
|
|
25856
|
-
this.header = {};
|
|
25857
|
-
this._header = {};
|
|
25852
|
+
this.header = {}; // preserves header name case
|
|
25853
|
+
this._header = {}; // coerces header names to lowercase
|
|
25858
25854
|
this.on('end', function(){
|
|
25859
25855
|
var err = null;
|
|
25860
25856
|
var res = null;
|
|
@@ -25867,6 +25863,8 @@ function Request(method, url) {
|
|
|
25867
25863
|
err.original = e;
|
|
25868
25864
|
// issue #675: return the raw response if the response parsing fails
|
|
25869
25865
|
err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
|
|
25866
|
+
// issue #876: return the http status code if the response parsing fails
|
|
25867
|
+
err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
|
|
25870
25868
|
return self.callback(err);
|
|
25871
25869
|
}
|
|
25872
25870
|
|
|
@@ -25876,140 +25874,32 @@ function Request(method, url) {
|
|
|
25876
25874
|
return self.callback(err, res);
|
|
25877
25875
|
}
|
|
25878
25876
|
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25877
|
+
try {
|
|
25878
|
+
if (res.status >= 200 && res.status < 300) {
|
|
25879
|
+
return self.callback(err, res);
|
|
25880
|
+
}
|
|
25882
25881
|
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
|
|
25886
|
-
|
|
25882
|
+
var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
|
|
25883
|
+
new_err.original = err;
|
|
25884
|
+
new_err.response = res;
|
|
25885
|
+
new_err.status = res.status;
|
|
25887
25886
|
|
|
25888
|
-
|
|
25887
|
+
self.callback(new_err, res);
|
|
25888
|
+
} catch(e) {
|
|
25889
|
+
self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android
|
|
25890
|
+
}
|
|
25889
25891
|
});
|
|
25890
25892
|
}
|
|
25891
25893
|
|
|
25892
25894
|
/**
|
|
25893
|
-
* Mixin `Emitter`.
|
|
25895
|
+
* Mixin `Emitter` and `requestBase`.
|
|
25894
25896
|
*/
|
|
25895
25897
|
|
|
25896
25898
|
Emitter(Request.prototype);
|
|
25897
|
-
|
|
25898
|
-
|
|
25899
|
-
* Allow for extension
|
|
25900
|
-
*/
|
|
25901
|
-
|
|
25902
|
-
Request.prototype.use = function(fn) {
|
|
25903
|
-
fn(this);
|
|
25904
|
-
return this;
|
|
25899
|
+
for (var key in requestBase) {
|
|
25900
|
+
Request.prototype[key] = requestBase[key];
|
|
25905
25901
|
}
|
|
25906
25902
|
|
|
25907
|
-
/**
|
|
25908
|
-
* Set timeout to `ms`.
|
|
25909
|
-
*
|
|
25910
|
-
* @param {Number} ms
|
|
25911
|
-
* @return {Request} for chaining
|
|
25912
|
-
* @api public
|
|
25913
|
-
*/
|
|
25914
|
-
|
|
25915
|
-
Request.prototype.timeout = function(ms){
|
|
25916
|
-
this._timeout = ms;
|
|
25917
|
-
return this;
|
|
25918
|
-
};
|
|
25919
|
-
|
|
25920
|
-
/**
|
|
25921
|
-
* Clear previous timeout.
|
|
25922
|
-
*
|
|
25923
|
-
* @return {Request} for chaining
|
|
25924
|
-
* @api public
|
|
25925
|
-
*/
|
|
25926
|
-
|
|
25927
|
-
Request.prototype.clearTimeout = function(){
|
|
25928
|
-
this._timeout = 0;
|
|
25929
|
-
clearTimeout(this._timer);
|
|
25930
|
-
return this;
|
|
25931
|
-
};
|
|
25932
|
-
|
|
25933
|
-
/**
|
|
25934
|
-
* Abort the request, and clear potential timeout.
|
|
25935
|
-
*
|
|
25936
|
-
* @return {Request}
|
|
25937
|
-
* @api public
|
|
25938
|
-
*/
|
|
25939
|
-
|
|
25940
|
-
Request.prototype.abort = function(){
|
|
25941
|
-
if (this.aborted) return;
|
|
25942
|
-
this.aborted = true;
|
|
25943
|
-
this.xhr.abort();
|
|
25944
|
-
this.clearTimeout();
|
|
25945
|
-
this.emit('abort');
|
|
25946
|
-
return this;
|
|
25947
|
-
};
|
|
25948
|
-
|
|
25949
|
-
/**
|
|
25950
|
-
* Set header `field` to `val`, or multiple fields with one object.
|
|
25951
|
-
*
|
|
25952
|
-
* Examples:
|
|
25953
|
-
*
|
|
25954
|
-
* req.get('/')
|
|
25955
|
-
* .set('Accept', 'application/json')
|
|
25956
|
-
* .set('X-API-Key', 'foobar')
|
|
25957
|
-
* .end(callback);
|
|
25958
|
-
*
|
|
25959
|
-
* req.get('/')
|
|
25960
|
-
* .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
|
|
25961
|
-
* .end(callback);
|
|
25962
|
-
*
|
|
25963
|
-
* @param {String|Object} field
|
|
25964
|
-
* @param {String} val
|
|
25965
|
-
* @return {Request} for chaining
|
|
25966
|
-
* @api public
|
|
25967
|
-
*/
|
|
25968
|
-
|
|
25969
|
-
Request.prototype.set = function(field, val){
|
|
25970
|
-
if (isObject(field)) {
|
|
25971
|
-
for (var key in field) {
|
|
25972
|
-
this.set(key, field[key]);
|
|
25973
|
-
}
|
|
25974
|
-
return this;
|
|
25975
|
-
}
|
|
25976
|
-
this._header[field.toLowerCase()] = val;
|
|
25977
|
-
this.header[field] = val;
|
|
25978
|
-
return this;
|
|
25979
|
-
};
|
|
25980
|
-
|
|
25981
|
-
/**
|
|
25982
|
-
* Remove header `field`.
|
|
25983
|
-
*
|
|
25984
|
-
* Example:
|
|
25985
|
-
*
|
|
25986
|
-
* req.get('/')
|
|
25987
|
-
* .unset('User-Agent')
|
|
25988
|
-
* .end(callback);
|
|
25989
|
-
*
|
|
25990
|
-
* @param {String} field
|
|
25991
|
-
* @return {Request} for chaining
|
|
25992
|
-
* @api public
|
|
25993
|
-
*/
|
|
25994
|
-
|
|
25995
|
-
Request.prototype.unset = function(field){
|
|
25996
|
-
delete this._header[field.toLowerCase()];
|
|
25997
|
-
delete this.header[field];
|
|
25998
|
-
return this;
|
|
25999
|
-
};
|
|
26000
|
-
|
|
26001
|
-
/**
|
|
26002
|
-
* Get case-insensitive header `field` value.
|
|
26003
|
-
*
|
|
26004
|
-
* @param {String} field
|
|
26005
|
-
* @return {String}
|
|
26006
|
-
* @api private
|
|
26007
|
-
*/
|
|
26008
|
-
|
|
26009
|
-
Request.prototype.getHeader = function(field){
|
|
26010
|
-
return this._header[field.toLowerCase()];
|
|
26011
|
-
};
|
|
26012
|
-
|
|
26013
25903
|
/**
|
|
26014
25904
|
* Set Content-Type to `type`, mapping values from `request.types`.
|
|
26015
25905
|
*
|
|
@@ -26038,16 +25928,22 @@ Request.prototype.type = function(type){
|
|
|
26038
25928
|
};
|
|
26039
25929
|
|
|
26040
25930
|
/**
|
|
26041
|
-
*
|
|
25931
|
+
* Set responseType to `val`. Presently valid responseTypes are 'blob' and
|
|
25932
|
+
* 'arraybuffer'.
|
|
26042
25933
|
*
|
|
26043
|
-
*
|
|
25934
|
+
* Examples:
|
|
26044
25935
|
*
|
|
26045
|
-
*
|
|
25936
|
+
* req.get('/')
|
|
25937
|
+
* .responseType('blob')
|
|
25938
|
+
* .end(callback);
|
|
25939
|
+
*
|
|
25940
|
+
* @param {String} val
|
|
25941
|
+
* @return {Request} for chaining
|
|
26046
25942
|
* @api public
|
|
26047
25943
|
*/
|
|
26048
25944
|
|
|
26049
|
-
Request.prototype.
|
|
26050
|
-
this.
|
|
25945
|
+
Request.prototype.responseType = function(val){
|
|
25946
|
+
this._responseType = val;
|
|
26051
25947
|
return this;
|
|
26052
25948
|
};
|
|
26053
25949
|
|
|
@@ -26081,13 +25977,29 @@ Request.prototype.accept = function(type){
|
|
|
26081
25977
|
*
|
|
26082
25978
|
* @param {String} user
|
|
26083
25979
|
* @param {String} pass
|
|
25980
|
+
* @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')
|
|
26084
25981
|
* @return {Request} for chaining
|
|
26085
25982
|
* @api public
|
|
26086
25983
|
*/
|
|
26087
25984
|
|
|
26088
|
-
Request.prototype.auth = function(user, pass){
|
|
26089
|
-
|
|
26090
|
-
|
|
25985
|
+
Request.prototype.auth = function(user, pass, options){
|
|
25986
|
+
if (!options) {
|
|
25987
|
+
options = {
|
|
25988
|
+
type: 'basic'
|
|
25989
|
+
}
|
|
25990
|
+
}
|
|
25991
|
+
|
|
25992
|
+
switch (options.type) {
|
|
25993
|
+
case 'basic':
|
|
25994
|
+
var str = btoa(user + ':' + pass);
|
|
25995
|
+
this.set('Authorization', 'Basic ' + str);
|
|
25996
|
+
break;
|
|
25997
|
+
|
|
25998
|
+
case 'auto':
|
|
25999
|
+
this.username = user;
|
|
26000
|
+
this.password = pass;
|
|
26001
|
+
break;
|
|
26002
|
+
}
|
|
26091
26003
|
return this;
|
|
26092
26004
|
};
|
|
26093
26005
|
|
|
@@ -26112,50 +26024,624 @@ Request.prototype.query = function(val){
|
|
|
26112
26024
|
};
|
|
26113
26025
|
|
|
26114
26026
|
/**
|
|
26115
|
-
*
|
|
26116
|
-
*
|
|
26027
|
+
* Queue the given `file` as an attachment to the specified `field`,
|
|
26028
|
+
* with optional `filename`.
|
|
26117
26029
|
*
|
|
26118
26030
|
* ``` js
|
|
26119
26031
|
* request.post('/upload')
|
|
26120
|
-
* .
|
|
26032
|
+
* .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
|
|
26121
26033
|
* .end(callback);
|
|
26122
26034
|
* ```
|
|
26123
26035
|
*
|
|
26124
|
-
* @param {String}
|
|
26125
|
-
* @param {
|
|
26036
|
+
* @param {String} field
|
|
26037
|
+
* @param {Blob|File} file
|
|
26038
|
+
* @param {String} filename
|
|
26126
26039
|
* @return {Request} for chaining
|
|
26127
26040
|
* @api public
|
|
26128
26041
|
*/
|
|
26129
26042
|
|
|
26130
|
-
Request.prototype.
|
|
26131
|
-
|
|
26132
|
-
this._formData.append(name, val);
|
|
26043
|
+
Request.prototype.attach = function(field, file, filename){
|
|
26044
|
+
this._getFormData().append(field, file, filename || file.name);
|
|
26133
26045
|
return this;
|
|
26134
26046
|
};
|
|
26135
26047
|
|
|
26048
|
+
Request.prototype._getFormData = function(){
|
|
26049
|
+
if (!this._formData) {
|
|
26050
|
+
this._formData = new root.FormData();
|
|
26051
|
+
}
|
|
26052
|
+
return this._formData;
|
|
26053
|
+
};
|
|
26054
|
+
|
|
26136
26055
|
/**
|
|
26137
|
-
*
|
|
26138
|
-
*
|
|
26056
|
+
* Invoke the callback with `err` and `res`
|
|
26057
|
+
* and handle arity check.
|
|
26058
|
+
*
|
|
26059
|
+
* @param {Error} err
|
|
26060
|
+
* @param {Response} res
|
|
26061
|
+
* @api private
|
|
26062
|
+
*/
|
|
26063
|
+
|
|
26064
|
+
Request.prototype.callback = function(err, res){
|
|
26065
|
+
var fn = this._callback;
|
|
26066
|
+
this.clearTimeout();
|
|
26067
|
+
fn(err, res);
|
|
26068
|
+
};
|
|
26069
|
+
|
|
26070
|
+
/**
|
|
26071
|
+
* Invoke callback with x-domain error.
|
|
26072
|
+
*
|
|
26073
|
+
* @api private
|
|
26074
|
+
*/
|
|
26075
|
+
|
|
26076
|
+
Request.prototype.crossDomainError = function(){
|
|
26077
|
+
var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
|
|
26078
|
+
err.crossDomain = true;
|
|
26079
|
+
|
|
26080
|
+
err.status = this.status;
|
|
26081
|
+
err.method = this.method;
|
|
26082
|
+
err.url = this.url;
|
|
26083
|
+
|
|
26084
|
+
this.callback(err);
|
|
26085
|
+
};
|
|
26086
|
+
|
|
26087
|
+
/**
|
|
26088
|
+
* Invoke callback with timeout error.
|
|
26089
|
+
*
|
|
26090
|
+
* @api private
|
|
26091
|
+
*/
|
|
26092
|
+
|
|
26093
|
+
Request.prototype._timeoutError = function(){
|
|
26094
|
+
var timeout = this._timeout;
|
|
26095
|
+
var err = new Error('timeout of ' + timeout + 'ms exceeded');
|
|
26096
|
+
err.timeout = timeout;
|
|
26097
|
+
this.callback(err);
|
|
26098
|
+
};
|
|
26099
|
+
|
|
26100
|
+
/**
|
|
26101
|
+
* Compose querystring to append to req.url
|
|
26102
|
+
*
|
|
26103
|
+
* @api private
|
|
26104
|
+
*/
|
|
26105
|
+
|
|
26106
|
+
Request.prototype._appendQueryString = function(){
|
|
26107
|
+
var query = this._query.join('&');
|
|
26108
|
+
if (query) {
|
|
26109
|
+
this.url += ~this.url.indexOf('?')
|
|
26110
|
+
? '&' + query
|
|
26111
|
+
: '?' + query;
|
|
26112
|
+
}
|
|
26113
|
+
};
|
|
26114
|
+
|
|
26115
|
+
/**
|
|
26116
|
+
* Initiate request, invoking callback `fn(res)`
|
|
26117
|
+
* with an instanceof `Response`.
|
|
26118
|
+
*
|
|
26119
|
+
* @param {Function} fn
|
|
26120
|
+
* @return {Request} for chaining
|
|
26121
|
+
* @api public
|
|
26122
|
+
*/
|
|
26123
|
+
|
|
26124
|
+
Request.prototype.end = function(fn){
|
|
26125
|
+
var self = this;
|
|
26126
|
+
var xhr = this.xhr = request.getXHR();
|
|
26127
|
+
var timeout = this._timeout;
|
|
26128
|
+
var data = this._formData || this._data;
|
|
26129
|
+
|
|
26130
|
+
// store callback
|
|
26131
|
+
this._callback = fn || noop;
|
|
26132
|
+
|
|
26133
|
+
// state change
|
|
26134
|
+
xhr.onreadystatechange = function(){
|
|
26135
|
+
if (4 != xhr.readyState) return;
|
|
26136
|
+
|
|
26137
|
+
// In IE9, reads to any property (e.g. status) off of an aborted XHR will
|
|
26138
|
+
// result in the error "Could not complete the operation due to error c00c023f"
|
|
26139
|
+
var status;
|
|
26140
|
+
try { status = xhr.status } catch(e) { status = 0; }
|
|
26141
|
+
|
|
26142
|
+
if (0 == status) {
|
|
26143
|
+
if (self.timedout) return self._timeoutError();
|
|
26144
|
+
if (self._aborted) return;
|
|
26145
|
+
return self.crossDomainError();
|
|
26146
|
+
}
|
|
26147
|
+
self.emit('end');
|
|
26148
|
+
};
|
|
26149
|
+
|
|
26150
|
+
// progress
|
|
26151
|
+
var handleProgress = function(e){
|
|
26152
|
+
if (e.total > 0) {
|
|
26153
|
+
e.percent = e.loaded / e.total * 100;
|
|
26154
|
+
}
|
|
26155
|
+
e.direction = 'download';
|
|
26156
|
+
self.emit('progress', e);
|
|
26157
|
+
};
|
|
26158
|
+
if (this.hasListeners('progress')) {
|
|
26159
|
+
xhr.onprogress = handleProgress;
|
|
26160
|
+
}
|
|
26161
|
+
try {
|
|
26162
|
+
if (xhr.upload && this.hasListeners('progress')) {
|
|
26163
|
+
xhr.upload.onprogress = handleProgress;
|
|
26164
|
+
}
|
|
26165
|
+
} catch(e) {
|
|
26166
|
+
// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
|
|
26167
|
+
// Reported here:
|
|
26168
|
+
// https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
|
|
26169
|
+
}
|
|
26170
|
+
|
|
26171
|
+
// timeout
|
|
26172
|
+
if (timeout && !this._timer) {
|
|
26173
|
+
this._timer = setTimeout(function(){
|
|
26174
|
+
self.timedout = true;
|
|
26175
|
+
self.abort();
|
|
26176
|
+
}, timeout);
|
|
26177
|
+
}
|
|
26178
|
+
|
|
26179
|
+
// querystring
|
|
26180
|
+
this._appendQueryString();
|
|
26181
|
+
|
|
26182
|
+
// initiate request
|
|
26183
|
+
if (this.username && this.password) {
|
|
26184
|
+
xhr.open(this.method, this.url, true, this.username, this.password);
|
|
26185
|
+
} else {
|
|
26186
|
+
xhr.open(this.method, this.url, true);
|
|
26187
|
+
}
|
|
26188
|
+
|
|
26189
|
+
// CORS
|
|
26190
|
+
if (this._withCredentials) xhr.withCredentials = true;
|
|
26191
|
+
|
|
26192
|
+
// body
|
|
26193
|
+
if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
|
|
26194
|
+
// serialize stuff
|
|
26195
|
+
var contentType = this._header['content-type'];
|
|
26196
|
+
var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
26197
|
+
if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
|
|
26198
|
+
if (serialize) data = serialize(data);
|
|
26199
|
+
}
|
|
26200
|
+
|
|
26201
|
+
// set header fields
|
|
26202
|
+
for (var field in this.header) {
|
|
26203
|
+
if (null == this.header[field]) continue;
|
|
26204
|
+
xhr.setRequestHeader(field, this.header[field]);
|
|
26205
|
+
}
|
|
26206
|
+
|
|
26207
|
+
if (this._responseType) {
|
|
26208
|
+
xhr.responseType = this._responseType;
|
|
26209
|
+
}
|
|
26210
|
+
|
|
26211
|
+
// send stuff
|
|
26212
|
+
this.emit('request', this);
|
|
26213
|
+
|
|
26214
|
+
// IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)
|
|
26215
|
+
// We need null here if data is undefined
|
|
26216
|
+
xhr.send(typeof data !== 'undefined' ? data : null);
|
|
26217
|
+
return this;
|
|
26218
|
+
};
|
|
26219
|
+
|
|
26220
|
+
|
|
26221
|
+
/**
|
|
26222
|
+
* Expose `Request`.
|
|
26223
|
+
*/
|
|
26224
|
+
|
|
26225
|
+
request.Request = Request;
|
|
26226
|
+
|
|
26227
|
+
/**
|
|
26228
|
+
* GET `url` with optional callback `fn(res)`.
|
|
26229
|
+
*
|
|
26230
|
+
* @param {String} url
|
|
26231
|
+
* @param {Mixed|Function} data or fn
|
|
26232
|
+
* @param {Function} fn
|
|
26233
|
+
* @return {Request}
|
|
26234
|
+
* @api public
|
|
26235
|
+
*/
|
|
26236
|
+
|
|
26237
|
+
request.get = function(url, data, fn){
|
|
26238
|
+
var req = request('GET', url);
|
|
26239
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26240
|
+
if (data) req.query(data);
|
|
26241
|
+
if (fn) req.end(fn);
|
|
26242
|
+
return req;
|
|
26243
|
+
};
|
|
26244
|
+
|
|
26245
|
+
/**
|
|
26246
|
+
* HEAD `url` with optional callback `fn(res)`.
|
|
26247
|
+
*
|
|
26248
|
+
* @param {String} url
|
|
26249
|
+
* @param {Mixed|Function} data or fn
|
|
26250
|
+
* @param {Function} fn
|
|
26251
|
+
* @return {Request}
|
|
26252
|
+
* @api public
|
|
26253
|
+
*/
|
|
26254
|
+
|
|
26255
|
+
request.head = function(url, data, fn){
|
|
26256
|
+
var req = request('HEAD', url);
|
|
26257
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26258
|
+
if (data) req.send(data);
|
|
26259
|
+
if (fn) req.end(fn);
|
|
26260
|
+
return req;
|
|
26261
|
+
};
|
|
26262
|
+
|
|
26263
|
+
/**
|
|
26264
|
+
* OPTIONS query to `url` with optional callback `fn(res)`.
|
|
26265
|
+
*
|
|
26266
|
+
* @param {String} url
|
|
26267
|
+
* @param {Mixed|Function} data or fn
|
|
26268
|
+
* @param {Function} fn
|
|
26269
|
+
* @return {Request}
|
|
26270
|
+
* @api public
|
|
26271
|
+
*/
|
|
26272
|
+
|
|
26273
|
+
request.options = function(url, data, fn){
|
|
26274
|
+
var req = request('OPTIONS', url);
|
|
26275
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26276
|
+
if (data) req.send(data);
|
|
26277
|
+
if (fn) req.end(fn);
|
|
26278
|
+
return req;
|
|
26279
|
+
};
|
|
26280
|
+
|
|
26281
|
+
/**
|
|
26282
|
+
* DELETE `url` with optional callback `fn(res)`.
|
|
26283
|
+
*
|
|
26284
|
+
* @param {String} url
|
|
26285
|
+
* @param {Function} fn
|
|
26286
|
+
* @return {Request}
|
|
26287
|
+
* @api public
|
|
26288
|
+
*/
|
|
26289
|
+
|
|
26290
|
+
function del(url, fn){
|
|
26291
|
+
var req = request('DELETE', url);
|
|
26292
|
+
if (fn) req.end(fn);
|
|
26293
|
+
return req;
|
|
26294
|
+
};
|
|
26295
|
+
|
|
26296
|
+
request['del'] = del;
|
|
26297
|
+
request['delete'] = del;
|
|
26298
|
+
|
|
26299
|
+
/**
|
|
26300
|
+
* PATCH `url` with optional `data` and callback `fn(res)`.
|
|
26301
|
+
*
|
|
26302
|
+
* @param {String} url
|
|
26303
|
+
* @param {Mixed} data
|
|
26304
|
+
* @param {Function} fn
|
|
26305
|
+
* @return {Request}
|
|
26306
|
+
* @api public
|
|
26307
|
+
*/
|
|
26308
|
+
|
|
26309
|
+
request.patch = function(url, data, fn){
|
|
26310
|
+
var req = request('PATCH', url);
|
|
26311
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26312
|
+
if (data) req.send(data);
|
|
26313
|
+
if (fn) req.end(fn);
|
|
26314
|
+
return req;
|
|
26315
|
+
};
|
|
26316
|
+
|
|
26317
|
+
/**
|
|
26318
|
+
* POST `url` with optional `data` and callback `fn(res)`.
|
|
26319
|
+
*
|
|
26320
|
+
* @param {String} url
|
|
26321
|
+
* @param {Mixed} data
|
|
26322
|
+
* @param {Function} fn
|
|
26323
|
+
* @return {Request}
|
|
26324
|
+
* @api public
|
|
26325
|
+
*/
|
|
26326
|
+
|
|
26327
|
+
request.post = function(url, data, fn){
|
|
26328
|
+
var req = request('POST', url);
|
|
26329
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26330
|
+
if (data) req.send(data);
|
|
26331
|
+
if (fn) req.end(fn);
|
|
26332
|
+
return req;
|
|
26333
|
+
};
|
|
26334
|
+
|
|
26335
|
+
/**
|
|
26336
|
+
* PUT `url` with optional `data` and callback `fn(res)`.
|
|
26337
|
+
*
|
|
26338
|
+
* @param {String} url
|
|
26339
|
+
* @param {Mixed|Function} data or fn
|
|
26340
|
+
* @param {Function} fn
|
|
26341
|
+
* @return {Request}
|
|
26342
|
+
* @api public
|
|
26343
|
+
*/
|
|
26344
|
+
|
|
26345
|
+
request.put = function(url, data, fn){
|
|
26346
|
+
var req = request('PUT', url);
|
|
26347
|
+
if ('function' == typeof data) fn = data, data = null;
|
|
26348
|
+
if (data) req.send(data);
|
|
26349
|
+
if (fn) req.end(fn);
|
|
26350
|
+
return req;
|
|
26351
|
+
};
|
|
26352
|
+
|
|
26353
|
+
},{"./is-object":90,"./request":92,"./request-base":91,"emitter":43,"reduce":80}],90:[function(require,module,exports){
|
|
26354
|
+
/**
|
|
26355
|
+
* Check if `obj` is an object.
|
|
26356
|
+
*
|
|
26357
|
+
* @param {Object} obj
|
|
26358
|
+
* @return {Boolean}
|
|
26359
|
+
* @api private
|
|
26360
|
+
*/
|
|
26361
|
+
|
|
26362
|
+
function isObject(obj) {
|
|
26363
|
+
return null !== obj && 'object' === typeof obj;
|
|
26364
|
+
}
|
|
26365
|
+
|
|
26366
|
+
module.exports = isObject;
|
|
26367
|
+
|
|
26368
|
+
},{}],91:[function(require,module,exports){
|
|
26369
|
+
/**
|
|
26370
|
+
* Module of mixed-in functions shared between node and client code
|
|
26371
|
+
*/
|
|
26372
|
+
var isObject = require('./is-object');
|
|
26373
|
+
|
|
26374
|
+
/**
|
|
26375
|
+
* Clear previous timeout.
|
|
26376
|
+
*
|
|
26377
|
+
* @return {Request} for chaining
|
|
26378
|
+
* @api public
|
|
26379
|
+
*/
|
|
26380
|
+
|
|
26381
|
+
exports.clearTimeout = function _clearTimeout(){
|
|
26382
|
+
this._timeout = 0;
|
|
26383
|
+
clearTimeout(this._timer);
|
|
26384
|
+
return this;
|
|
26385
|
+
};
|
|
26386
|
+
|
|
26387
|
+
/**
|
|
26388
|
+
* Override default response body parser
|
|
26389
|
+
*
|
|
26390
|
+
* This function will be called to convert incoming data into request.body
|
|
26391
|
+
*
|
|
26392
|
+
* @param {Function}
|
|
26393
|
+
* @api public
|
|
26394
|
+
*/
|
|
26395
|
+
|
|
26396
|
+
exports.parse = function parse(fn){
|
|
26397
|
+
this._parser = fn;
|
|
26398
|
+
return this;
|
|
26399
|
+
};
|
|
26400
|
+
|
|
26401
|
+
/**
|
|
26402
|
+
* Override default request body serializer
|
|
26403
|
+
*
|
|
26404
|
+
* This function will be called to convert data set via .send or .attach into payload to send
|
|
26405
|
+
*
|
|
26406
|
+
* @param {Function}
|
|
26407
|
+
* @api public
|
|
26408
|
+
*/
|
|
26409
|
+
|
|
26410
|
+
exports.serialize = function serialize(fn){
|
|
26411
|
+
this._serializer = fn;
|
|
26412
|
+
return this;
|
|
26413
|
+
};
|
|
26414
|
+
|
|
26415
|
+
/**
|
|
26416
|
+
* Set timeout to `ms`.
|
|
26417
|
+
*
|
|
26418
|
+
* @param {Number} ms
|
|
26419
|
+
* @return {Request} for chaining
|
|
26420
|
+
* @api public
|
|
26421
|
+
*/
|
|
26422
|
+
|
|
26423
|
+
exports.timeout = function timeout(ms){
|
|
26424
|
+
this._timeout = ms;
|
|
26425
|
+
return this;
|
|
26426
|
+
};
|
|
26427
|
+
|
|
26428
|
+
/**
|
|
26429
|
+
* Promise support
|
|
26430
|
+
*
|
|
26431
|
+
* @param {Function} resolve
|
|
26432
|
+
* @param {Function} reject
|
|
26433
|
+
* @return {Request}
|
|
26434
|
+
*/
|
|
26435
|
+
|
|
26436
|
+
exports.then = function then(resolve, reject) {
|
|
26437
|
+
if (!this._fullfilledPromise) {
|
|
26438
|
+
var self = this;
|
|
26439
|
+
this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
|
|
26440
|
+
self.end(function(err, res){
|
|
26441
|
+
if (err) innerReject(err); else innerResolve(res);
|
|
26442
|
+
});
|
|
26443
|
+
});
|
|
26444
|
+
}
|
|
26445
|
+
return this._fullfilledPromise.then(resolve, reject);
|
|
26446
|
+
}
|
|
26447
|
+
|
|
26448
|
+
/**
|
|
26449
|
+
* Allow for extension
|
|
26450
|
+
*/
|
|
26451
|
+
|
|
26452
|
+
exports.use = function use(fn) {
|
|
26453
|
+
fn(this);
|
|
26454
|
+
return this;
|
|
26455
|
+
}
|
|
26456
|
+
|
|
26457
|
+
|
|
26458
|
+
/**
|
|
26459
|
+
* Get request header `field`.
|
|
26460
|
+
* Case-insensitive.
|
|
26461
|
+
*
|
|
26462
|
+
* @param {String} field
|
|
26463
|
+
* @return {String}
|
|
26464
|
+
* @api public
|
|
26465
|
+
*/
|
|
26466
|
+
|
|
26467
|
+
exports.get = function(field){
|
|
26468
|
+
return this._header[field.toLowerCase()];
|
|
26469
|
+
};
|
|
26470
|
+
|
|
26471
|
+
/**
|
|
26472
|
+
* Get case-insensitive header `field` value.
|
|
26473
|
+
* This is a deprecated internal API. Use `.get(field)` instead.
|
|
26474
|
+
*
|
|
26475
|
+
* (getHeader is no longer used internally by the superagent code base)
|
|
26476
|
+
*
|
|
26477
|
+
* @param {String} field
|
|
26478
|
+
* @return {String}
|
|
26479
|
+
* @api private
|
|
26480
|
+
* @deprecated
|
|
26481
|
+
*/
|
|
26482
|
+
|
|
26483
|
+
exports.getHeader = exports.get;
|
|
26484
|
+
|
|
26485
|
+
/**
|
|
26486
|
+
* Set header `field` to `val`, or multiple fields with one object.
|
|
26487
|
+
* Case-insensitive.
|
|
26488
|
+
*
|
|
26489
|
+
* Examples:
|
|
26490
|
+
*
|
|
26491
|
+
* req.get('/')
|
|
26492
|
+
* .set('Accept', 'application/json')
|
|
26493
|
+
* .set('X-API-Key', 'foobar')
|
|
26494
|
+
* .end(callback);
|
|
26495
|
+
*
|
|
26496
|
+
* req.get('/')
|
|
26497
|
+
* .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
|
|
26498
|
+
* .end(callback);
|
|
26499
|
+
*
|
|
26500
|
+
* @param {String|Object} field
|
|
26501
|
+
* @param {String} val
|
|
26502
|
+
* @return {Request} for chaining
|
|
26503
|
+
* @api public
|
|
26504
|
+
*/
|
|
26505
|
+
|
|
26506
|
+
exports.set = function(field, val){
|
|
26507
|
+
if (isObject(field)) {
|
|
26508
|
+
for (var key in field) {
|
|
26509
|
+
this.set(key, field[key]);
|
|
26510
|
+
}
|
|
26511
|
+
return this;
|
|
26512
|
+
}
|
|
26513
|
+
this._header[field.toLowerCase()] = val;
|
|
26514
|
+
this.header[field] = val;
|
|
26515
|
+
return this;
|
|
26516
|
+
};
|
|
26517
|
+
|
|
26518
|
+
/**
|
|
26519
|
+
* Remove header `field`.
|
|
26520
|
+
* Case-insensitive.
|
|
26521
|
+
*
|
|
26522
|
+
* Example:
|
|
26523
|
+
*
|
|
26524
|
+
* req.get('/')
|
|
26525
|
+
* .unset('User-Agent')
|
|
26526
|
+
* .end(callback);
|
|
26527
|
+
*
|
|
26528
|
+
* @param {String} field
|
|
26529
|
+
*/
|
|
26530
|
+
exports.unset = function(field){
|
|
26531
|
+
delete this._header[field.toLowerCase()];
|
|
26532
|
+
delete this.header[field];
|
|
26533
|
+
return this;
|
|
26534
|
+
};
|
|
26535
|
+
|
|
26536
|
+
/**
|
|
26537
|
+
* Write the field `name` and `val` for "multipart/form-data"
|
|
26538
|
+
* request bodies.
|
|
26139
26539
|
*
|
|
26140
26540
|
* ``` js
|
|
26141
26541
|
* request.post('/upload')
|
|
26142
|
-
* .
|
|
26542
|
+
* .field('foo', 'bar')
|
|
26143
26543
|
* .end(callback);
|
|
26144
26544
|
* ```
|
|
26145
26545
|
*
|
|
26146
|
-
* @param {String}
|
|
26147
|
-
* @param {Blob|File}
|
|
26148
|
-
* @param {String} filename
|
|
26546
|
+
* @param {String} name
|
|
26547
|
+
* @param {String|Blob|File|Buffer|fs.ReadStream} val
|
|
26149
26548
|
* @return {Request} for chaining
|
|
26150
26549
|
* @api public
|
|
26151
26550
|
*/
|
|
26551
|
+
exports.field = function(name, val) {
|
|
26552
|
+
this._getFormData().append(name, val);
|
|
26553
|
+
return this;
|
|
26554
|
+
};
|
|
26152
26555
|
|
|
26153
|
-
|
|
26154
|
-
|
|
26155
|
-
|
|
26556
|
+
/**
|
|
26557
|
+
* Abort the request, and clear potential timeout.
|
|
26558
|
+
*
|
|
26559
|
+
* @return {Request}
|
|
26560
|
+
* @api public
|
|
26561
|
+
*/
|
|
26562
|
+
exports.abort = function(){
|
|
26563
|
+
if (this._aborted) {
|
|
26564
|
+
return this;
|
|
26565
|
+
}
|
|
26566
|
+
this._aborted = true;
|
|
26567
|
+
this.xhr && this.xhr.abort(); // browser
|
|
26568
|
+
this.req && this.req.abort(); // node
|
|
26569
|
+
this.clearTimeout();
|
|
26570
|
+
this.emit('abort');
|
|
26571
|
+
return this;
|
|
26572
|
+
};
|
|
26573
|
+
|
|
26574
|
+
/**
|
|
26575
|
+
* Enable transmission of cookies with x-domain requests.
|
|
26576
|
+
*
|
|
26577
|
+
* Note that for this to work the origin must not be
|
|
26578
|
+
* using "Access-Control-Allow-Origin" with a wildcard,
|
|
26579
|
+
* and also must set "Access-Control-Allow-Credentials"
|
|
26580
|
+
* to "true".
|
|
26581
|
+
*
|
|
26582
|
+
* @api public
|
|
26583
|
+
*/
|
|
26584
|
+
|
|
26585
|
+
exports.withCredentials = function(){
|
|
26586
|
+
// This is browser-only functionality. Node side is no-op.
|
|
26587
|
+
this._withCredentials = true;
|
|
26588
|
+
return this;
|
|
26589
|
+
};
|
|
26590
|
+
|
|
26591
|
+
/**
|
|
26592
|
+
* Set the max redirects to `n`. Does noting in browser XHR implementation.
|
|
26593
|
+
*
|
|
26594
|
+
* @param {Number} n
|
|
26595
|
+
* @return {Request} for chaining
|
|
26596
|
+
* @api public
|
|
26597
|
+
*/
|
|
26598
|
+
|
|
26599
|
+
exports.redirects = function(n){
|
|
26600
|
+
this._maxRedirects = n;
|
|
26156
26601
|
return this;
|
|
26157
26602
|
};
|
|
26158
26603
|
|
|
26604
|
+
/**
|
|
26605
|
+
* Convert to a plain javascript object (not JSON string) of scalar properties.
|
|
26606
|
+
* Note as this method is designed to return a useful non-this value,
|
|
26607
|
+
* it cannot be chained.
|
|
26608
|
+
*
|
|
26609
|
+
* @return {Object} describing method, url, and data of this request
|
|
26610
|
+
* @api public
|
|
26611
|
+
*/
|
|
26612
|
+
|
|
26613
|
+
exports.toJSON = function(){
|
|
26614
|
+
return {
|
|
26615
|
+
method: this.method,
|
|
26616
|
+
url: this.url,
|
|
26617
|
+
data: this._data
|
|
26618
|
+
};
|
|
26619
|
+
};
|
|
26620
|
+
|
|
26621
|
+
/**
|
|
26622
|
+
* Check if `obj` is a host object,
|
|
26623
|
+
* we don't want to serialize these :)
|
|
26624
|
+
*
|
|
26625
|
+
* TODO: future proof, move to compoent land
|
|
26626
|
+
*
|
|
26627
|
+
* @param {Object} obj
|
|
26628
|
+
* @return {Boolean}
|
|
26629
|
+
* @api private
|
|
26630
|
+
*/
|
|
26631
|
+
|
|
26632
|
+
exports._isHost = function _isHost(obj) {
|
|
26633
|
+
var str = {}.toString.call(obj);
|
|
26634
|
+
|
|
26635
|
+
switch (str) {
|
|
26636
|
+
case '[object File]':
|
|
26637
|
+
case '[object Blob]':
|
|
26638
|
+
case '[object FormData]':
|
|
26639
|
+
return true;
|
|
26640
|
+
default:
|
|
26641
|
+
return false;
|
|
26642
|
+
}
|
|
26643
|
+
}
|
|
26644
|
+
|
|
26159
26645
|
/**
|
|
26160
26646
|
* Send `data` as the request body, defaulting the `.type()` to "json" when
|
|
26161
26647
|
* an object is given.
|
|
@@ -26186,19 +26672,19 @@ Request.prototype.attach = function(field, file, filename){
|
|
|
26186
26672
|
* .end(callback)
|
|
26187
26673
|
*
|
|
26188
26674
|
* // defaults to x-www-form-urlencoded
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
|
|
26675
|
+
* request.post('/user')
|
|
26676
|
+
* .send('name=tobi')
|
|
26677
|
+
* .send('species=ferret')
|
|
26678
|
+
* .end(callback)
|
|
26193
26679
|
*
|
|
26194
26680
|
* @param {String|Object} data
|
|
26195
26681
|
* @return {Request} for chaining
|
|
26196
26682
|
* @api public
|
|
26197
26683
|
*/
|
|
26198
26684
|
|
|
26199
|
-
|
|
26685
|
+
exports.send = function(data){
|
|
26200
26686
|
var obj = isObject(data);
|
|
26201
|
-
var type = this.
|
|
26687
|
+
var type = this._header['content-type'];
|
|
26202
26688
|
|
|
26203
26689
|
// merge
|
|
26204
26690
|
if (obj && isObject(this._data)) {
|
|
@@ -26206,8 +26692,9 @@ Request.prototype.send = function(data){
|
|
|
26206
26692
|
this._data[key] = data[key];
|
|
26207
26693
|
}
|
|
26208
26694
|
} else if ('string' == typeof data) {
|
|
26695
|
+
// default to x-www-form-urlencoded
|
|
26209
26696
|
if (!type) this.type('form');
|
|
26210
|
-
type = this.
|
|
26697
|
+
type = this._header['content-type'];
|
|
26211
26698
|
if ('application/x-www-form-urlencoded' == type) {
|
|
26212
26699
|
this._data = this._data
|
|
26213
26700
|
? this._data + '&' + data
|
|
@@ -26219,195 +26706,16 @@ Request.prototype.send = function(data){
|
|
|
26219
26706
|
this._data = data;
|
|
26220
26707
|
}
|
|
26221
26708
|
|
|
26222
|
-
if (!obj ||
|
|
26223
|
-
if (!type) this.type('json');
|
|
26224
|
-
return this;
|
|
26225
|
-
};
|
|
26226
|
-
|
|
26227
|
-
/**
|
|
26228
|
-
* Invoke the callback with `err` and `res`
|
|
26229
|
-
* and handle arity check.
|
|
26230
|
-
*
|
|
26231
|
-
* @param {Error} err
|
|
26232
|
-
* @param {Response} res
|
|
26233
|
-
* @api private
|
|
26234
|
-
*/
|
|
26235
|
-
|
|
26236
|
-
Request.prototype.callback = function(err, res){
|
|
26237
|
-
var fn = this._callback;
|
|
26238
|
-
this.clearTimeout();
|
|
26239
|
-
fn(err, res);
|
|
26240
|
-
};
|
|
26241
|
-
|
|
26242
|
-
/**
|
|
26243
|
-
* Invoke callback with x-domain error.
|
|
26244
|
-
*
|
|
26245
|
-
* @api private
|
|
26246
|
-
*/
|
|
26247
|
-
|
|
26248
|
-
Request.prototype.crossDomainError = function(){
|
|
26249
|
-
var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
|
|
26250
|
-
err.crossDomain = true;
|
|
26251
|
-
|
|
26252
|
-
err.status = this.status;
|
|
26253
|
-
err.method = this.method;
|
|
26254
|
-
err.url = this.url;
|
|
26255
|
-
|
|
26256
|
-
this.callback(err);
|
|
26257
|
-
};
|
|
26258
|
-
|
|
26259
|
-
/**
|
|
26260
|
-
* Invoke callback with timeout error.
|
|
26261
|
-
*
|
|
26262
|
-
* @api private
|
|
26263
|
-
*/
|
|
26264
|
-
|
|
26265
|
-
Request.prototype.timeoutError = function(){
|
|
26266
|
-
var timeout = this._timeout;
|
|
26267
|
-
var err = new Error('timeout of ' + timeout + 'ms exceeded');
|
|
26268
|
-
err.timeout = timeout;
|
|
26269
|
-
this.callback(err);
|
|
26270
|
-
};
|
|
26271
|
-
|
|
26272
|
-
/**
|
|
26273
|
-
* Enable transmission of cookies with x-domain requests.
|
|
26274
|
-
*
|
|
26275
|
-
* Note that for this to work the origin must not be
|
|
26276
|
-
* using "Access-Control-Allow-Origin" with a wildcard,
|
|
26277
|
-
* and also must set "Access-Control-Allow-Credentials"
|
|
26278
|
-
* to "true".
|
|
26279
|
-
*
|
|
26280
|
-
* @api public
|
|
26281
|
-
*/
|
|
26282
|
-
|
|
26283
|
-
Request.prototype.withCredentials = function(){
|
|
26284
|
-
this._withCredentials = true;
|
|
26285
|
-
return this;
|
|
26286
|
-
};
|
|
26287
|
-
|
|
26288
|
-
/**
|
|
26289
|
-
* Initiate request, invoking callback `fn(res)`
|
|
26290
|
-
* with an instanceof `Response`.
|
|
26291
|
-
*
|
|
26292
|
-
* @param {Function} fn
|
|
26293
|
-
* @return {Request} for chaining
|
|
26294
|
-
* @api public
|
|
26295
|
-
*/
|
|
26296
|
-
|
|
26297
|
-
Request.prototype.end = function(fn){
|
|
26298
|
-
var self = this;
|
|
26299
|
-
var xhr = this.xhr = request.getXHR();
|
|
26300
|
-
var query = this._query.join('&');
|
|
26301
|
-
var timeout = this._timeout;
|
|
26302
|
-
var data = this._formData || this._data;
|
|
26303
|
-
|
|
26304
|
-
// store callback
|
|
26305
|
-
this._callback = fn || noop;
|
|
26306
|
-
|
|
26307
|
-
// state change
|
|
26308
|
-
xhr.onreadystatechange = function(){
|
|
26309
|
-
if (4 != xhr.readyState) return;
|
|
26310
|
-
|
|
26311
|
-
// In IE9, reads to any property (e.g. status) off of an aborted XHR will
|
|
26312
|
-
// result in the error "Could not complete the operation due to error c00c023f"
|
|
26313
|
-
var status;
|
|
26314
|
-
try { status = xhr.status } catch(e) { status = 0; }
|
|
26315
|
-
|
|
26316
|
-
if (0 == status) {
|
|
26317
|
-
if (self.timedout) return self.timeoutError();
|
|
26318
|
-
if (self.aborted) return;
|
|
26319
|
-
return self.crossDomainError();
|
|
26320
|
-
}
|
|
26321
|
-
self.emit('end');
|
|
26322
|
-
};
|
|
26323
|
-
|
|
26324
|
-
// progress
|
|
26325
|
-
var handleProgress = function(e){
|
|
26326
|
-
if (e.total > 0) {
|
|
26327
|
-
e.percent = e.loaded / e.total * 100;
|
|
26328
|
-
}
|
|
26329
|
-
e.direction = 'download';
|
|
26330
|
-
self.emit('progress', e);
|
|
26331
|
-
};
|
|
26332
|
-
if (this.hasListeners('progress')) {
|
|
26333
|
-
xhr.onprogress = handleProgress;
|
|
26334
|
-
}
|
|
26335
|
-
try {
|
|
26336
|
-
if (xhr.upload && this.hasListeners('progress')) {
|
|
26337
|
-
xhr.upload.onprogress = handleProgress;
|
|
26338
|
-
}
|
|
26339
|
-
} catch(e) {
|
|
26340
|
-
// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
|
|
26341
|
-
// Reported here:
|
|
26342
|
-
// https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
|
|
26343
|
-
}
|
|
26344
|
-
|
|
26345
|
-
// timeout
|
|
26346
|
-
if (timeout && !this._timer) {
|
|
26347
|
-
this._timer = setTimeout(function(){
|
|
26348
|
-
self.timedout = true;
|
|
26349
|
-
self.abort();
|
|
26350
|
-
}, timeout);
|
|
26351
|
-
}
|
|
26352
|
-
|
|
26353
|
-
// querystring
|
|
26354
|
-
if (query) {
|
|
26355
|
-
query = request.serializeObject(query);
|
|
26356
|
-
this.url += ~this.url.indexOf('?')
|
|
26357
|
-
? '&' + query
|
|
26358
|
-
: '?' + query;
|
|
26359
|
-
}
|
|
26360
|
-
|
|
26361
|
-
// initiate request
|
|
26362
|
-
xhr.open(this.method, this.url, true);
|
|
26363
|
-
|
|
26364
|
-
// CORS
|
|
26365
|
-
if (this._withCredentials) xhr.withCredentials = true;
|
|
26366
|
-
|
|
26367
|
-
// body
|
|
26368
|
-
if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
|
|
26369
|
-
// serialize stuff
|
|
26370
|
-
var contentType = this.getHeader('Content-Type');
|
|
26371
|
-
var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
26372
|
-
if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
|
|
26373
|
-
if (serialize) data = serialize(data);
|
|
26374
|
-
}
|
|
26709
|
+
if (!obj || this._isHost(data)) return this;
|
|
26375
26710
|
|
|
26376
|
-
//
|
|
26377
|
-
|
|
26378
|
-
if (null == this.header[field]) continue;
|
|
26379
|
-
xhr.setRequestHeader(field, this.header[field]);
|
|
26380
|
-
}
|
|
26381
|
-
|
|
26382
|
-
// send stuff
|
|
26383
|
-
this.emit('request', this);
|
|
26384
|
-
|
|
26385
|
-
// IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)
|
|
26386
|
-
// We need null here if data is undefined
|
|
26387
|
-
xhr.send(typeof data !== 'undefined' ? data : null);
|
|
26711
|
+
// default to json
|
|
26712
|
+
if (!type) this.type('json');
|
|
26388
26713
|
return this;
|
|
26389
26714
|
};
|
|
26390
26715
|
|
|
26391
|
-
|
|
26392
|
-
|
|
26393
|
-
|
|
26394
|
-
* @param {Function} fulfill
|
|
26395
|
-
* @param {Function} reject
|
|
26396
|
-
* @return {Request}
|
|
26397
|
-
*/
|
|
26398
|
-
|
|
26399
|
-
Request.prototype.then = function (fulfill, reject) {
|
|
26400
|
-
return this.end(function(err, res) {
|
|
26401
|
-
err ? reject(err) : fulfill(res);
|
|
26402
|
-
});
|
|
26403
|
-
}
|
|
26404
|
-
|
|
26405
|
-
/**
|
|
26406
|
-
* Expose `Request`.
|
|
26407
|
-
*/
|
|
26408
|
-
|
|
26409
|
-
request.Request = Request;
|
|
26410
|
-
|
|
26716
|
+
},{"./is-object":90}],92:[function(require,module,exports){
|
|
26717
|
+
// The node and browser modules expose versions of this with the
|
|
26718
|
+
// appropriate constructor function bound as first argument
|
|
26411
26719
|
/**
|
|
26412
26720
|
* Issue a request:
|
|
26413
26721
|
*
|
|
@@ -26423,135 +26731,23 @@ request.Request = Request;
|
|
|
26423
26731
|
* @api public
|
|
26424
26732
|
*/
|
|
26425
26733
|
|
|
26426
|
-
function request(method, url) {
|
|
26734
|
+
function request(RequestConstructor, method, url) {
|
|
26427
26735
|
// callback
|
|
26428
26736
|
if ('function' == typeof url) {
|
|
26429
|
-
return new
|
|
26737
|
+
return new RequestConstructor('GET', method).end(url);
|
|
26430
26738
|
}
|
|
26431
26739
|
|
|
26432
26740
|
// url first
|
|
26433
|
-
if (
|
|
26434
|
-
return new
|
|
26741
|
+
if (2 == arguments.length) {
|
|
26742
|
+
return new RequestConstructor('GET', method);
|
|
26435
26743
|
}
|
|
26436
26744
|
|
|
26437
|
-
return new
|
|
26745
|
+
return new RequestConstructor(method, url);
|
|
26438
26746
|
}
|
|
26439
26747
|
|
|
26440
|
-
/**
|
|
26441
|
-
* GET `url` with optional callback `fn(res)`.
|
|
26442
|
-
*
|
|
26443
|
-
* @param {String} url
|
|
26444
|
-
* @param {Mixed|Function} data or fn
|
|
26445
|
-
* @param {Function} fn
|
|
26446
|
-
* @return {Request}
|
|
26447
|
-
* @api public
|
|
26448
|
-
*/
|
|
26449
|
-
|
|
26450
|
-
request.get = function(url, data, fn){
|
|
26451
|
-
var req = request('GET', url);
|
|
26452
|
-
if ('function' == typeof data) fn = data, data = null;
|
|
26453
|
-
if (data) req.query(data);
|
|
26454
|
-
if (fn) req.end(fn);
|
|
26455
|
-
return req;
|
|
26456
|
-
};
|
|
26457
|
-
|
|
26458
|
-
/**
|
|
26459
|
-
* HEAD `url` with optional callback `fn(res)`.
|
|
26460
|
-
*
|
|
26461
|
-
* @param {String} url
|
|
26462
|
-
* @param {Mixed|Function} data or fn
|
|
26463
|
-
* @param {Function} fn
|
|
26464
|
-
* @return {Request}
|
|
26465
|
-
* @api public
|
|
26466
|
-
*/
|
|
26467
|
-
|
|
26468
|
-
request.head = function(url, data, fn){
|
|
26469
|
-
var req = request('HEAD', url);
|
|
26470
|
-
if ('function' == typeof data) fn = data, data = null;
|
|
26471
|
-
if (data) req.send(data);
|
|
26472
|
-
if (fn) req.end(fn);
|
|
26473
|
-
return req;
|
|
26474
|
-
};
|
|
26475
|
-
|
|
26476
|
-
/**
|
|
26477
|
-
* DELETE `url` with optional callback `fn(res)`.
|
|
26478
|
-
*
|
|
26479
|
-
* @param {String} url
|
|
26480
|
-
* @param {Function} fn
|
|
26481
|
-
* @return {Request}
|
|
26482
|
-
* @api public
|
|
26483
|
-
*/
|
|
26484
|
-
|
|
26485
|
-
function del(url, fn){
|
|
26486
|
-
var req = request('DELETE', url);
|
|
26487
|
-
if (fn) req.end(fn);
|
|
26488
|
-
return req;
|
|
26489
|
-
};
|
|
26490
|
-
|
|
26491
|
-
request['del'] = del;
|
|
26492
|
-
request['delete'] = del;
|
|
26493
|
-
|
|
26494
|
-
/**
|
|
26495
|
-
* PATCH `url` with optional `data` and callback `fn(res)`.
|
|
26496
|
-
*
|
|
26497
|
-
* @param {String} url
|
|
26498
|
-
* @param {Mixed} data
|
|
26499
|
-
* @param {Function} fn
|
|
26500
|
-
* @return {Request}
|
|
26501
|
-
* @api public
|
|
26502
|
-
*/
|
|
26503
|
-
|
|
26504
|
-
request.patch = function(url, data, fn){
|
|
26505
|
-
var req = request('PATCH', url);
|
|
26506
|
-
if ('function' == typeof data) fn = data, data = null;
|
|
26507
|
-
if (data) req.send(data);
|
|
26508
|
-
if (fn) req.end(fn);
|
|
26509
|
-
return req;
|
|
26510
|
-
};
|
|
26511
|
-
|
|
26512
|
-
/**
|
|
26513
|
-
* POST `url` with optional `data` and callback `fn(res)`.
|
|
26514
|
-
*
|
|
26515
|
-
* @param {String} url
|
|
26516
|
-
* @param {Mixed} data
|
|
26517
|
-
* @param {Function} fn
|
|
26518
|
-
* @return {Request}
|
|
26519
|
-
* @api public
|
|
26520
|
-
*/
|
|
26521
|
-
|
|
26522
|
-
request.post = function(url, data, fn){
|
|
26523
|
-
var req = request('POST', url);
|
|
26524
|
-
if ('function' == typeof data) fn = data, data = null;
|
|
26525
|
-
if (data) req.send(data);
|
|
26526
|
-
if (fn) req.end(fn);
|
|
26527
|
-
return req;
|
|
26528
|
-
};
|
|
26529
|
-
|
|
26530
|
-
/**
|
|
26531
|
-
* PUT `url` with optional `data` and callback `fn(res)`.
|
|
26532
|
-
*
|
|
26533
|
-
* @param {String} url
|
|
26534
|
-
* @param {Mixed|Function} data or fn
|
|
26535
|
-
* @param {Function} fn
|
|
26536
|
-
* @return {Request}
|
|
26537
|
-
* @api public
|
|
26538
|
-
*/
|
|
26539
|
-
|
|
26540
|
-
request.put = function(url, data, fn){
|
|
26541
|
-
var req = request('PUT', url);
|
|
26542
|
-
if ('function' == typeof data) fn = data, data = null;
|
|
26543
|
-
if (data) req.send(data);
|
|
26544
|
-
if (fn) req.end(fn);
|
|
26545
|
-
return req;
|
|
26546
|
-
};
|
|
26547
|
-
|
|
26548
|
-
/**
|
|
26549
|
-
* Expose `request`.
|
|
26550
|
-
*/
|
|
26551
|
-
|
|
26552
26748
|
module.exports = request;
|
|
26553
26749
|
|
|
26554
|
-
},{
|
|
26750
|
+
},{}],93:[function(require,module,exports){
|
|
26555
26751
|
(function (Buffer){
|
|
26556
26752
|
"0.50.0";
|
|
26557
26753
|
/*
|
|
@@ -34748,7 +34944,7 @@ TinCan client library
|
|
|
34748
34944
|
}());
|
|
34749
34945
|
|
|
34750
34946
|
}).call(this,require("buffer").Buffer)
|
|
34751
|
-
},{"buffer":40,"querystring":62,"xhr2":
|
|
34947
|
+
},{"buffer":40,"querystring":62,"xhr2":97}],94:[function(require,module,exports){
|
|
34752
34948
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
34753
34949
|
//
|
|
34754
34950
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -35457,7 +35653,7 @@ function isNullOrUndefined(arg) {
|
|
|
35457
35653
|
return arg == null;
|
|
35458
35654
|
}
|
|
35459
35655
|
|
|
35460
|
-
},{"punycode":58,"querystring":62}],
|
|
35656
|
+
},{"punycode":58,"querystring":62}],95:[function(require,module,exports){
|
|
35461
35657
|
(function (global){
|
|
35462
35658
|
|
|
35463
35659
|
/**
|
|
@@ -35528,7 +35724,7 @@ function config (name) {
|
|
|
35528
35724
|
}
|
|
35529
35725
|
|
|
35530
35726
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
35531
|
-
},{}],
|
|
35727
|
+
},{}],96:[function(require,module,exports){
|
|
35532
35728
|
/*!
|
|
35533
35729
|
* validate.js 0.9.0
|
|
35534
35730
|
*
|
|
@@ -36616,7 +36812,7 @@ function config (name) {
|
|
|
36616
36812
|
typeof module !== 'undefined' ? /* istanbul ignore next */ module : null,
|
|
36617
36813
|
typeof define !== 'undefined' ? /* istanbul ignore next */ define : null);
|
|
36618
36814
|
|
|
36619
|
-
},{}],
|
|
36815
|
+
},{}],97:[function(require,module,exports){
|
|
36620
36816
|
(function (process,Buffer){
|
|
36621
36817
|
// Generated by CoffeeScript 1.6.3
|
|
36622
36818
|
(function() {
|
|
@@ -37454,7 +37650,7 @@ function config (name) {
|
|
|
37454
37650
|
}).call(this);
|
|
37455
37651
|
|
|
37456
37652
|
}).call(this,require('_process'),require("buffer").Buffer)
|
|
37457
|
-
},{"_process":56,"buffer":40,"http":83,"https":48,"os":54,"url":
|
|
37653
|
+
},{"_process":56,"buffer":40,"http":83,"https":48,"os":54,"url":94}],98:[function(require,module,exports){
|
|
37458
37654
|
module.exports = extend
|
|
37459
37655
|
|
|
37460
37656
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|