forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.js
More file actions
27 lines (22 loc) · 786 Bytes
/
Copy pathnode.js
File metadata and controls
27 lines (22 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import superagent from 'superagent';
import AgentKeepAlive from 'agentkeepalive';
import superagentProxy from '../proxyAgent';
let keepAliveAgent = null;
let keepAliveSecureAgent = null;
superagentProxy(superagent);
export function proxy(superagentConstruct) {
return superagentConstruct.proxy(this._config.proxy);
}
export function keepAlive(superagentConstruct) {
let agent = this._config.secure ? keepAliveSecureAgent : keepAliveAgent;
if (agent === null) {
const AgentClass = this._config.secure ? AgentKeepAlive.HttpsAgent : AgentKeepAlive;
agent = new AgentClass(this._config.keepAliveSettings);
if (this._config.secure) {
keepAliveSecureAgent = agent;
} else {
keepAliveAgent = agent;
}
}
return superagentConstruct.agent(agent);
}