Skip to content

Commit ad9a881

Browse files
committed
Fix connectionAgent behavior to apply to both spec fetch and requests, and to leave the request object alone in favor of the INSTANCE of the request
1 parent e694dcd commit ad9a881

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ SwaggerClient.prototype.buildFromSpec = function (response) {
406406
}
407407

408408
// get paths, create functions for each operationId
409-
409+
410410
// Bind help to 'client.apis'
411411
self.apis.help = _.bind(self.help, self);
412412

@@ -447,6 +447,7 @@ SwaggerClient.prototype.buildFromSpec = function (response) {
447447
self.models,
448448
self.clientAuthorizations);
449449

450+
operationObject.connectionAgent = self.connectionAgent;
450451
operationObject.vendorExtensions = {};
451452
for(i in operation) {
452453
helpers.extractExtensions(i, operationObject, operation[i]);

lib/http.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ JQueryHttpClient.prototype.execute = function (obj) {
216216
};
217217

218218
SuperagentHttpClient.prototype.execute = function (obj) {
219-
var connectionAgent = obj.connectionAgent;
220219
var method = obj.method.toLowerCase();
221220
var timeout = obj.timeout;
222221

@@ -225,12 +224,12 @@ SuperagentHttpClient.prototype.execute = function (obj) {
225224
}
226225
var headers = obj.headers || {};
227226

228-
if (connectionAgent) {
229-
request = request.agent(connectionAgent);
230-
}
231-
232227
var r = request[method](obj.url);
233228

229+
if (obj.connectionAgent) {
230+
r.agent(obj.connectionAgent);
231+
}
232+
234233
if (timeout) {
235234
r.timeout(timeout);
236235
}

lib/types/operation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
860860
headers: headers,
861861
clientAuthorizations: opts.clientAuthorizations,
862862
operation: this.operation,
863+
connectionAgent: this.connectionAgent,
863864
on: {
864865
response: function (response) {
865866
if (deferred) {

0 commit comments

Comments
 (0)