Skip to content

Commit fe1cfbc

Browse files
authored
Merge pull request #875 from gas-buddy/support-custom-agent
add support for adding a custom http(s) agent
2 parents 2f3e3e3 + 7e2b911 commit fe1cfbc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
136136
this.defaultSuccessCallback = options.defaultSuccessCallback || null;
137137
this.defaultErrorCallback = options.defaultErrorCallback || null;
138138
this.modelPropertyMacro = options.modelPropertyMacro || null;
139+
this.connectionAgent = options.connectionAgent || null;
139140
this.parameterMacro = options.parameterMacro || null;
140141
this.usePromise = options.usePromise || null;
141142

@@ -201,6 +202,7 @@ SwaggerClient.prototype.build = function (mock) {
201202
var obj = {
202203
useJQuery: this.useJQuery,
203204
jqueryAjaxCache: this.jqueryAjaxCache,
205+
connectionAgent: this.connectionAgent,
204206
url: this.url,
205207
method: 'get',
206208
headers: {

lib/http.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ JQueryHttpClient.prototype.execute = function (obj) {
207207
};
208208

209209
SuperagentHttpClient.prototype.execute = function (obj) {
210+
var connectionAgent = obj.connectionAgent;
210211
var method = obj.method.toLowerCase();
211212
var timeout = obj.timeout;
212213

@@ -216,6 +217,10 @@ SuperagentHttpClient.prototype.execute = function (obj) {
216217
var headers = obj.headers || {};
217218
var r = request[method](obj.url);
218219

220+
if (connectionAgent) {
221+
r.agent(connectionAgent);
222+
}
223+
219224
if (timeout) {
220225
r.timeout(timeout);
221226
}

0 commit comments

Comments
 (0)