request: make pool an explicit option.
This commit is contained in:
parent
22c5014c49
commit
aa07255d74
@ -197,6 +197,7 @@ HTTPClient.prototype._request = co(function* _request(method, endpoint, json) {
|
||||
res = yield request({
|
||||
method: method,
|
||||
uri: this.uri + endpoint,
|
||||
pool: true,
|
||||
query: query,
|
||||
json: json,
|
||||
auth: {
|
||||
|
||||
@ -36,6 +36,7 @@ function RequestOptions(options) {
|
||||
this.ssl = false;
|
||||
this.method = 'GET';
|
||||
this.strictSSL = true;
|
||||
this.pool = false;
|
||||
this.agent = USER_AGENT;
|
||||
|
||||
this.type = null;
|
||||
@ -106,16 +107,21 @@ RequestOptions.prototype.fromOptions = function fromOptions(options) {
|
||||
this.method = options.method.toUpperCase();
|
||||
}
|
||||
|
||||
if (options.agent != null) {
|
||||
assert(typeof options.agent === 'string');
|
||||
this.agent = options.agent;
|
||||
}
|
||||
|
||||
if (options.strictSSL != null) {
|
||||
assert(typeof options.strictSSL === 'boolean');
|
||||
this.strictSSL = options.strictSSL;
|
||||
}
|
||||
|
||||
if (options.pool != null) {
|
||||
assert(typeof options.pool === 'boolean');
|
||||
this.pool = options.pool;
|
||||
}
|
||||
|
||||
if (options.agent != null) {
|
||||
assert(typeof options.agent === 'string');
|
||||
this.agent = options.agent;
|
||||
}
|
||||
|
||||
if (options.auth != null) {
|
||||
assert(typeof options.auth === 'object');
|
||||
assert(typeof options.auth.username === 'string');
|
||||
@ -225,6 +231,7 @@ RequestOptions.prototype.toHTTP = function toHTTP() {
|
||||
port: this.port,
|
||||
path: this.path + query,
|
||||
headers: headers,
|
||||
agent: this.pool ? null : false,
|
||||
rejectUnauthorized: this.strictSSL
|
||||
};
|
||||
};
|
||||
@ -314,13 +321,6 @@ Request.prototype.close = function close() {
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
if (this.response.socket) {
|
||||
try {
|
||||
this.response.socket.destroy();
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.cleanup();
|
||||
@ -443,13 +443,6 @@ Request.prototype._onResponse = function _onResponse(response) {
|
||||
this.response.on('data', this.onData);
|
||||
this.response.on('error', this.onEnd);
|
||||
this.response.on('end', this.onEnd);
|
||||
|
||||
if (this.response.socket) {
|
||||
this.response.socket.on('error', this.onEnd);
|
||||
// An agent socket's `end` sometimes
|
||||
// won't be emitted on the response.
|
||||
this.response.socket.on('end', this.onEnd);
|
||||
}
|
||||
};
|
||||
|
||||
Request.prototype._onData = function _onData(data) {
|
||||
|
||||
@ -48,6 +48,7 @@ RPCClient.prototype.call = co(function* call(method, params) {
|
||||
var res = yield request.promise({
|
||||
method: 'POST',
|
||||
uri: this.uri,
|
||||
pool: true,
|
||||
json: {
|
||||
method: method,
|
||||
params: params,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user