mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
[JavaScript] Handle custom request.agent (#6737)
* Handle custom request.agent * better semantic
This commit is contained in:
parent
d0ec683a86
commit
649811d542
@ -91,6 +91,10 @@
|
||||
this.agent = new superagent.agent();
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow user to override superagent agent
|
||||
*/
|
||||
this.requestAgent = null;
|
||||
};
|
||||
|
||||
{{#emitJSDoc}} /**
|
||||
@ -408,6 +412,12 @@
|
||||
// set header parameters
|
||||
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
|
||||
|
||||
|
||||
// set requestAgent if it is set by user
|
||||
if (this.requestAgent) {
|
||||
request.agent(this.requestAgent);
|
||||
}
|
||||
|
||||
// set request timeout
|
||||
request.timeout(this.timeout);
|
||||
|
||||
|
@ -78,6 +78,12 @@ export default class ApiClient {
|
||||
if (typeof window === 'undefined') {
|
||||
this.agent = new superagent.agent();
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow user to override superagent agent
|
||||
*/
|
||||
this.requestAgent = null;
|
||||
|
||||
}
|
||||
|
||||
{{#emitJSDoc}}/**
|
||||
@ -396,6 +402,11 @@ export default class ApiClient {
|
||||
// set header parameters
|
||||
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
|
||||
|
||||
// set requestAgent if it is set by user
|
||||
if (this.requestAgent) {
|
||||
request.agent(this.requestAgent);
|
||||
}
|
||||
|
||||
// set request timeout
|
||||
request.timeout(this.timeout);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user