superagent 3.5.1 → 3.6.0
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/History.md +8 -0
- package/Makefile +2 -2
- package/Readme.md +3 -3
- package/changelog.sh +7 -0
- package/docs/head.html +1 -0
- package/docs/index.md +65 -69
- package/docs/style.css +5 -0
- package/docs/tail.html +14 -7
- package/lib/client.js +6 -33
- package/lib/node/index.js +41 -50
- package/lib/request-base.js +30 -1
- package/package.json +16 -16
- package/superagent.js +43 -58
- package/yarn.lock +3889 -0
- package/lib/is-function.js +0 -15
package/lib/node/index.js
CHANGED
|
@@ -24,7 +24,6 @@ var zlib = require('zlib');
|
|
|
24
24
|
var util = require('util');
|
|
25
25
|
var pkg = require('../../package.json');
|
|
26
26
|
var RequestBase = require('../request-base');
|
|
27
|
-
var isFunction = require('../is-function');
|
|
28
27
|
var shouldRetry = require('../should-retry');
|
|
29
28
|
|
|
30
29
|
var request = exports = module.exports = function(method, url) {
|
|
@@ -144,7 +143,8 @@ function Request(method, url) {
|
|
|
144
143
|
this.redirects(method === 'HEAD' ? 0 : 5);
|
|
145
144
|
this.cookies = '';
|
|
146
145
|
this.qs = {};
|
|
147
|
-
this.
|
|
146
|
+
this._query = [];
|
|
147
|
+
this.qsRaw = this._query; // Unused, for backwards compatibility only
|
|
148
148
|
this._redirectList = [];
|
|
149
149
|
this._streamRequest = false;
|
|
150
150
|
this.once('end', this.clearTimeout.bind(this));
|
|
@@ -306,11 +306,10 @@ Request.prototype.accept = function(type){
|
|
|
306
306
|
|
|
307
307
|
Request.prototype.query = function(val){
|
|
308
308
|
if ('string' == typeof val) {
|
|
309
|
-
this.
|
|
310
|
-
|
|
309
|
+
this._query.push(val);
|
|
310
|
+
} else {
|
|
311
|
+
extend(this.qs, val);
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
-
extend(this.qs, val);
|
|
314
313
|
return this;
|
|
315
314
|
};
|
|
316
315
|
|
|
@@ -452,7 +451,7 @@ Request.prototype._redirect = function(res){
|
|
|
452
451
|
this._endCalled = false;
|
|
453
452
|
this.url = url;
|
|
454
453
|
this.qs = {};
|
|
455
|
-
this.
|
|
454
|
+
this._query.length = 0;
|
|
456
455
|
this.set(headers);
|
|
457
456
|
this.emit('redirect', res);
|
|
458
457
|
this._redirectList.push(this.url);
|
|
@@ -485,12 +484,12 @@ Request.prototype.auth = function(user, pass, options){
|
|
|
485
484
|
}
|
|
486
485
|
switch (options.type) {
|
|
487
486
|
case 'bearer':
|
|
488
|
-
return this.set('Authorization', 'Bearer ' + user);
|
|
489
|
-
|
|
487
|
+
return this.set('Authorization', 'Bearer ' + user);
|
|
488
|
+
|
|
490
489
|
default: // 'basic'
|
|
491
490
|
if (!~user.indexOf(':')) user = user + ':';
|
|
492
491
|
var str = new Buffer(user + pass).toString('base64');
|
|
493
|
-
return this.set('Authorization', 'Basic ' + str);
|
|
492
|
+
return this.set('Authorization', 'Basic ' + str);
|
|
494
493
|
}
|
|
495
494
|
};
|
|
496
495
|
|
|
@@ -529,7 +528,12 @@ Request.prototype.key = function(cert){
|
|
|
529
528
|
*/
|
|
530
529
|
|
|
531
530
|
Request.prototype.pfx = function(cert){
|
|
532
|
-
|
|
531
|
+
if(typeof cert === 'object' && !Buffer.isBuffer(cert)){
|
|
532
|
+
this._pfx = cert.pfx;
|
|
533
|
+
this._passphrase = cert.passphrase;
|
|
534
|
+
} else {
|
|
535
|
+
this._pfx = cert;
|
|
536
|
+
}
|
|
533
537
|
return this;
|
|
534
538
|
};
|
|
535
539
|
|
|
@@ -558,6 +562,18 @@ Request.prototype.request = function(){
|
|
|
558
562
|
|
|
559
563
|
var self = this;
|
|
560
564
|
var options = {};
|
|
565
|
+
|
|
566
|
+
try {
|
|
567
|
+
var query = qs.stringify(this.qs, { indices: false, strictNullHandling: true });
|
|
568
|
+
if (query) {
|
|
569
|
+
this.qs = {};
|
|
570
|
+
this._query.push(query);
|
|
571
|
+
}
|
|
572
|
+
this._finalizeQueryString();
|
|
573
|
+
} catch (e) {
|
|
574
|
+
return this.emit('error', e);
|
|
575
|
+
}
|
|
576
|
+
|
|
561
577
|
var url = this.url;
|
|
562
578
|
var retries = this._retries;
|
|
563
579
|
|
|
@@ -573,18 +589,19 @@ Request.prototype.request = function(){
|
|
|
573
589
|
// get the socket, path
|
|
574
590
|
var unixParts = url.path.match(/^([^/]+)(.+)$/);
|
|
575
591
|
options.socketPath = unixParts[1].replace(/%2F/g, '/');
|
|
576
|
-
url.
|
|
592
|
+
url.path = unixParts[2];
|
|
577
593
|
}
|
|
578
594
|
|
|
579
595
|
// options
|
|
580
596
|
options.method = this.method;
|
|
581
597
|
options.port = url.port;
|
|
582
|
-
options.path = url.
|
|
598
|
+
options.path = url.path;
|
|
583
599
|
options.host = url.hostname;
|
|
584
600
|
options.ca = this._ca;
|
|
585
601
|
options.key = this._key;
|
|
586
602
|
options.pfx = this._pfx;
|
|
587
603
|
options.cert = this._cert;
|
|
604
|
+
options.passphrase = this._passphrase;
|
|
588
605
|
options.agent = this._agent;
|
|
589
606
|
|
|
590
607
|
// initiate request
|
|
@@ -592,6 +609,10 @@ Request.prototype.request = function(){
|
|
|
592
609
|
|
|
593
610
|
// request
|
|
594
611
|
var req = this.req = mod.request(options);
|
|
612
|
+
|
|
613
|
+
// set tcp no delay
|
|
614
|
+
req.setNoDelay(true);
|
|
615
|
+
|
|
595
616
|
if ('HEAD' != options.method) {
|
|
596
617
|
req.setHeader('Accept-Encoding', 'gzip, deflate');
|
|
597
618
|
}
|
|
@@ -621,10 +642,6 @@ Request.prototype.request = function(){
|
|
|
621
642
|
this.auth(auth[0], auth[1]);
|
|
622
643
|
}
|
|
623
644
|
|
|
624
|
-
// query
|
|
625
|
-
if (url.search)
|
|
626
|
-
this.query(url.search.substr(1));
|
|
627
|
-
|
|
628
645
|
// add cookies
|
|
629
646
|
if (this.cookies) req.setHeader('Cookie', this.cookies);
|
|
630
647
|
|
|
@@ -633,12 +650,6 @@ Request.prototype.request = function(){
|
|
|
633
650
|
req.setHeader(key, this.header[key]);
|
|
634
651
|
}
|
|
635
652
|
|
|
636
|
-
try {
|
|
637
|
-
this._appendQueryString(req);
|
|
638
|
-
} catch (e) {
|
|
639
|
-
return this.emit('error', e);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
653
|
return req;
|
|
643
654
|
};
|
|
644
655
|
|
|
@@ -688,32 +699,6 @@ Request.prototype.callback = function(err, res){
|
|
|
688
699
|
fn(err, res);
|
|
689
700
|
};
|
|
690
701
|
|
|
691
|
-
/**
|
|
692
|
-
* Compose querystring to append to req.path
|
|
693
|
-
*
|
|
694
|
-
* @return {String} querystring
|
|
695
|
-
* @api private
|
|
696
|
-
*/
|
|
697
|
-
|
|
698
|
-
Request.prototype._appendQueryString = function(req){
|
|
699
|
-
var query = qs.stringify(this.qs, { indices: false, strictNullHandling: true });
|
|
700
|
-
query += ((query.length && this.qsRaw.length) ? '&' : '') + this.qsRaw.join('&');
|
|
701
|
-
req.path += query.length ? (~req.path.indexOf('?') ? '&' : '?') + query : '';
|
|
702
|
-
|
|
703
|
-
if (this._sort) {
|
|
704
|
-
var index = req.path.indexOf('?');
|
|
705
|
-
if (index >= 0) {
|
|
706
|
-
var queryArr = req.path.substring(index + 1).split('&');
|
|
707
|
-
if (isFunction(this._sort)) {
|
|
708
|
-
queryArr.sort(this._sort);
|
|
709
|
-
} else {
|
|
710
|
-
queryArr.sort();
|
|
711
|
-
}
|
|
712
|
-
req.path = req.path.substring(0, index) + '?' + queryArr.join('&');
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
|
|
717
702
|
/**
|
|
718
703
|
* Check if `obj` is a host object,
|
|
719
704
|
*
|
|
@@ -999,7 +984,13 @@ methods.forEach(function(method){
|
|
|
999
984
|
request[name] = function(url, data, fn){
|
|
1000
985
|
var req = request(method, url);
|
|
1001
986
|
if ('function' == typeof data) fn = data, data = null;
|
|
1002
|
-
if (data)
|
|
987
|
+
if (data) {
|
|
988
|
+
if (method === 'GET' || method === 'HEAD') {
|
|
989
|
+
req.query(data);
|
|
990
|
+
} else {
|
|
991
|
+
req.send(data);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
1003
994
|
fn && req.end(fn);
|
|
1004
995
|
return req;
|
|
1005
996
|
};
|
package/lib/request-base.js
CHANGED
|
@@ -108,7 +108,7 @@ RequestBase.prototype.serialize = function serialize(fn){
|
|
|
108
108
|
*
|
|
109
109
|
* Value of 0 or false means no timeout.
|
|
110
110
|
*
|
|
111
|
-
* @param {Number|Object} ms or {response,
|
|
111
|
+
* @param {Number|Object} ms or {response, deadline}
|
|
112
112
|
* @return {Request} for chaining
|
|
113
113
|
* @api public
|
|
114
114
|
*/
|
|
@@ -554,6 +554,35 @@ RequestBase.prototype.sortQuery = function(sort) {
|
|
|
554
554
|
return this;
|
|
555
555
|
};
|
|
556
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Compose querystring to append to req.url
|
|
559
|
+
*
|
|
560
|
+
* @api private
|
|
561
|
+
*/
|
|
562
|
+
RequestBase.prototype._finalizeQueryString = function(){
|
|
563
|
+
var query = this._query.join('&');
|
|
564
|
+
if (query) {
|
|
565
|
+
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query;
|
|
566
|
+
}
|
|
567
|
+
this._query.length = 0; // Makes the call idempotent
|
|
568
|
+
|
|
569
|
+
if (this._sort) {
|
|
570
|
+
var index = this.url.indexOf('?');
|
|
571
|
+
if (index >= 0) {
|
|
572
|
+
var queryArr = this.url.substring(index + 1).split('&');
|
|
573
|
+
if ('function' === typeof this._sort) {
|
|
574
|
+
queryArr.sort(this._sort);
|
|
575
|
+
} else {
|
|
576
|
+
queryArr.sort();
|
|
577
|
+
}
|
|
578
|
+
this.url = this.url.substring(0, index) + '?' + queryArr.join('&');
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// For backwards compat only
|
|
584
|
+
RequestBase.prototype._appendQueryString = function() {console.trace("Unsupported");}
|
|
585
|
+
|
|
557
586
|
/**
|
|
558
587
|
* Invoke callback with timeout error.
|
|
559
588
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "superagent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "elegant & feature rich browser / node HTTP with a fluent API",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublish": "make all",
|
|
@@ -25,29 +25,29 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"component-emitter": "^1.2.0",
|
|
28
|
-
"cookiejar": "^2.0
|
|
29
|
-
"debug": "^2.
|
|
28
|
+
"cookiejar": "^2.1.0",
|
|
29
|
+
"debug": "^2.6.0",
|
|
30
30
|
"extend": "^3.0.0",
|
|
31
31
|
"form-data": "^2.1.1",
|
|
32
32
|
"formidable": "^1.1.1",
|
|
33
33
|
"methods": "^1.1.1",
|
|
34
|
-
"mime": "^1.3.
|
|
35
|
-
"qs": "^6.
|
|
34
|
+
"mime": "^1.3.6",
|
|
35
|
+
"qs": "^6.4.0",
|
|
36
36
|
"readable-stream": "^2.0.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"Base64": "^1.0.
|
|
39
|
+
"Base64": "^1.0.1",
|
|
40
40
|
"basic-auth-connect": "^1.0.0",
|
|
41
|
-
"body-parser": "^1.
|
|
42
|
-
"browserify": "^14.
|
|
43
|
-
"cookie-parser": "^1.4.
|
|
44
|
-
"express": "^4.
|
|
45
|
-
"express-session": "^1.
|
|
46
|
-
"marked": "^0.3.
|
|
41
|
+
"body-parser": "^1.17.0",
|
|
42
|
+
"browserify": "^14.1.0",
|
|
43
|
+
"cookie-parser": "^1.4.3",
|
|
44
|
+
"express": "^4.15.2",
|
|
45
|
+
"express-session": "^1.15.0",
|
|
46
|
+
"marked": "^0.3.6",
|
|
47
47
|
"mocha": "^3.1.2",
|
|
48
|
-
"multer": "^1.
|
|
49
|
-
"should": "^11.
|
|
50
|
-
"should-http": "^0.
|
|
48
|
+
"multer": "^1.3.0",
|
|
49
|
+
"should": "^11.2.0",
|
|
50
|
+
"should-http": "^0.1.1",
|
|
51
51
|
"zuul": "^3.11.1"
|
|
52
52
|
},
|
|
53
53
|
"browser": {
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
},
|
|
62
62
|
"main": "./lib/node/index.js",
|
|
63
63
|
"engines": {
|
|
64
|
-
"node": ">= 0
|
|
64
|
+
"node": ">= 4.0"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/superagent.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
(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){
|
|
2
|
-
/**
|
|
3
|
-
* Check if `fn` is a function.
|
|
4
|
-
*
|
|
5
|
-
* @param {Function} fn
|
|
6
|
-
* @return {Boolean}
|
|
7
|
-
* @api private
|
|
8
|
-
*/
|
|
9
|
-
var isObject = require('./is-object');
|
|
10
|
-
|
|
11
|
-
function isFunction(fn) {
|
|
12
|
-
var tag = isObject(fn) ? Object.prototype.toString.call(fn) : '';
|
|
13
|
-
return tag === '[object Function]';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = isFunction;
|
|
17
|
-
|
|
18
|
-
},{"./is-object":2}],2:[function(require,module,exports){
|
|
19
2
|
/**
|
|
20
3
|
* Check if `obj` is an object.
|
|
21
4
|
*
|
|
@@ -30,7 +13,7 @@ function isObject(obj) {
|
|
|
30
13
|
|
|
31
14
|
module.exports = isObject;
|
|
32
15
|
|
|
33
|
-
},{}],
|
|
16
|
+
},{}],2:[function(require,module,exports){
|
|
34
17
|
/**
|
|
35
18
|
* Module of mixed-in functions shared between node and client code
|
|
36
19
|
*/
|
|
@@ -141,7 +124,7 @@ RequestBase.prototype.serialize = function serialize(fn){
|
|
|
141
124
|
*
|
|
142
125
|
* Value of 0 or false means no timeout.
|
|
143
126
|
*
|
|
144
|
-
* @param {Number|Object} ms or {response,
|
|
127
|
+
* @param {Number|Object} ms or {response, deadline}
|
|
145
128
|
* @return {Request} for chaining
|
|
146
129
|
* @api public
|
|
147
130
|
*/
|
|
@@ -587,6 +570,35 @@ RequestBase.prototype.sortQuery = function(sort) {
|
|
|
587
570
|
return this;
|
|
588
571
|
};
|
|
589
572
|
|
|
573
|
+
/**
|
|
574
|
+
* Compose querystring to append to req.url
|
|
575
|
+
*
|
|
576
|
+
* @api private
|
|
577
|
+
*/
|
|
578
|
+
RequestBase.prototype._finalizeQueryString = function(){
|
|
579
|
+
var query = this._query.join('&');
|
|
580
|
+
if (query) {
|
|
581
|
+
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query;
|
|
582
|
+
}
|
|
583
|
+
this._query.length = 0; // Makes the call idempotent
|
|
584
|
+
|
|
585
|
+
if (this._sort) {
|
|
586
|
+
var index = this.url.indexOf('?');
|
|
587
|
+
if (index >= 0) {
|
|
588
|
+
var queryArr = this.url.substring(index + 1).split('&');
|
|
589
|
+
if ('function' === typeof this._sort) {
|
|
590
|
+
queryArr.sort(this._sort);
|
|
591
|
+
} else {
|
|
592
|
+
queryArr.sort();
|
|
593
|
+
}
|
|
594
|
+
this.url = this.url.substring(0, index) + '?' + queryArr.join('&');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// For backwards compat only
|
|
600
|
+
RequestBase.prototype._appendQueryString = function() {console.trace("Unsupported");}
|
|
601
|
+
|
|
590
602
|
/**
|
|
591
603
|
* Invoke callback with timeout error.
|
|
592
604
|
*
|
|
@@ -623,7 +635,7 @@ RequestBase.prototype._setTimeouts = function() {
|
|
|
623
635
|
}
|
|
624
636
|
}
|
|
625
637
|
|
|
626
|
-
},{"./is-object":
|
|
638
|
+
},{"./is-object":1}],3:[function(require,module,exports){
|
|
627
639
|
|
|
628
640
|
/**
|
|
629
641
|
* Module dependencies.
|
|
@@ -758,7 +770,7 @@ ResponseBase.prototype._setStatusProperties = function(status){
|
|
|
758
770
|
this.notFound = 404 == status;
|
|
759
771
|
};
|
|
760
772
|
|
|
761
|
-
},{"./utils":
|
|
773
|
+
},{"./utils":5}],4:[function(require,module,exports){
|
|
762
774
|
var ERROR_CODES = [
|
|
763
775
|
'ECONNRESET',
|
|
764
776
|
'ETIMEDOUT',
|
|
@@ -783,7 +795,7 @@ module.exports = function shouldRetry(err, res) {
|
|
|
783
795
|
return false;
|
|
784
796
|
};
|
|
785
797
|
|
|
786
|
-
},{}],
|
|
798
|
+
},{}],5:[function(require,module,exports){
|
|
787
799
|
|
|
788
800
|
/**
|
|
789
801
|
* Return the mime type for the given `str`.
|
|
@@ -852,7 +864,7 @@ exports.cleanHeader = function(header, shouldStripCookie){
|
|
|
852
864
|
}
|
|
853
865
|
return header;
|
|
854
866
|
};
|
|
855
|
-
},{}],
|
|
867
|
+
},{}],6:[function(require,module,exports){
|
|
856
868
|
|
|
857
869
|
/**
|
|
858
870
|
* Expose `Emitter`.
|
|
@@ -1017,7 +1029,7 @@ Emitter.prototype.hasListeners = function(event){
|
|
|
1017
1029
|
return !! this.listeners(event).length;
|
|
1018
1030
|
};
|
|
1019
1031
|
|
|
1020
|
-
},{}],
|
|
1032
|
+
},{}],7:[function(require,module,exports){
|
|
1021
1033
|
/**
|
|
1022
1034
|
* Root reference for iframes.
|
|
1023
1035
|
*/
|
|
@@ -1035,7 +1047,6 @@ if (typeof window !== 'undefined') { // Browser window
|
|
|
1035
1047
|
var Emitter = require('component-emitter');
|
|
1036
1048
|
var RequestBase = require('./request-base');
|
|
1037
1049
|
var isObject = require('./is-object');
|
|
1038
|
-
var isFunction = require('./is-function');
|
|
1039
1050
|
var ResponseBase = require('./response-base');
|
|
1040
1051
|
var shouldRetry = require('./should-retry');
|
|
1041
1052
|
|
|
@@ -1080,7 +1091,7 @@ request.getXHR = function () {
|
|
|
1080
1091
|
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
|
|
1081
1092
|
try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
|
|
1082
1093
|
}
|
|
1083
|
-
throw Error("Browser-only
|
|
1094
|
+
throw Error("Browser-only version of superagent could not find XHR");
|
|
1084
1095
|
};
|
|
1085
1096
|
|
|
1086
1097
|
/**
|
|
@@ -1190,7 +1201,7 @@ request.parseString = parseString;
|
|
|
1190
1201
|
request.types = {
|
|
1191
1202
|
html: 'text/html',
|
|
1192
1203
|
json: 'application/json',
|
|
1193
|
-
xml: '
|
|
1204
|
+
xml: 'text/xml',
|
|
1194
1205
|
urlencoded: 'application/x-www-form-urlencoded',
|
|
1195
1206
|
'form': 'application/x-www-form-urlencoded',
|
|
1196
1207
|
'form-data': 'application/x-www-form-urlencoded'
|
|
@@ -1546,10 +1557,10 @@ Request.prototype.auth = function(user, pass, options){
|
|
|
1546
1557
|
this.username = user;
|
|
1547
1558
|
this.password = pass;
|
|
1548
1559
|
break;
|
|
1549
|
-
|
|
1560
|
+
|
|
1550
1561
|
case 'bearer': // usage would be .auth(accessToken, { type: 'bearer' })
|
|
1551
1562
|
this.set('Authorization', 'Bearer ' + user);
|
|
1552
|
-
break;
|
|
1563
|
+
break;
|
|
1553
1564
|
}
|
|
1554
1565
|
return this;
|
|
1555
1566
|
};
|
|
@@ -1663,32 +1674,6 @@ Request.prototype.pipe = Request.prototype.write = function(){
|
|
|
1663
1674
|
throw Error("Streaming is not supported in browser version of superagent");
|
|
1664
1675
|
};
|
|
1665
1676
|
|
|
1666
|
-
/**
|
|
1667
|
-
* Compose querystring to append to req.url
|
|
1668
|
-
*
|
|
1669
|
-
* @api private
|
|
1670
|
-
*/
|
|
1671
|
-
|
|
1672
|
-
Request.prototype._appendQueryString = function(){
|
|
1673
|
-
var query = this._query.join('&');
|
|
1674
|
-
if (query) {
|
|
1675
|
-
this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
if (this._sort) {
|
|
1679
|
-
var index = this.url.indexOf('?');
|
|
1680
|
-
if (index >= 0) {
|
|
1681
|
-
var queryArr = this.url.substring(index + 1).split('&');
|
|
1682
|
-
if (isFunction(this._sort)) {
|
|
1683
|
-
queryArr.sort(this._sort);
|
|
1684
|
-
} else {
|
|
1685
|
-
queryArr.sort();
|
|
1686
|
-
}
|
|
1687
|
-
this.url = this.url.substring(0, index) + '?' + queryArr.join('&');
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
};
|
|
1691
|
-
|
|
1692
1677
|
/**
|
|
1693
1678
|
* Check if `obj` is a host object,
|
|
1694
1679
|
* we don't want to serialize these :)
|
|
@@ -1721,7 +1706,7 @@ Request.prototype.end = function(fn){
|
|
|
1721
1706
|
this._callback = fn || noop;
|
|
1722
1707
|
|
|
1723
1708
|
// querystring
|
|
1724
|
-
this.
|
|
1709
|
+
this._finalizeQueryString();
|
|
1725
1710
|
|
|
1726
1711
|
return this._end();
|
|
1727
1712
|
};
|
|
@@ -1854,7 +1839,7 @@ request.get = function(url, data, fn){
|
|
|
1854
1839
|
request.head = function(url, data, fn){
|
|
1855
1840
|
var req = request('HEAD', url);
|
|
1856
1841
|
if ('function' == typeof data) fn = data, data = null;
|
|
1857
|
-
if (data) req.
|
|
1842
|
+
if (data) req.query(data);
|
|
1858
1843
|
if (fn) req.end(fn);
|
|
1859
1844
|
return req;
|
|
1860
1845
|
};
|
|
@@ -1952,5 +1937,5 @@ request.put = function(url, data, fn){
|
|
|
1952
1937
|
return req;
|
|
1953
1938
|
};
|
|
1954
1939
|
|
|
1955
|
-
},{"./is-
|
|
1940
|
+
},{"./is-object":1,"./request-base":2,"./response-base":3,"./should-retry":4,"component-emitter":6}]},{},[7])(7)
|
|
1956
1941
|
});
|