Skip to content

Commit 3f84f43

Browse files
committed
fix: do not instantaie a proxy for eahc request
1 parent df30d13 commit 3f84f43

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

packages/xen-api/src/transports/json-rpc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ import UnsupportedTransport from './_UnsupportedTransport'
88

99
// https://github.com/xenserver/xenadmin/blob/0df39a9d83cd82713f32d24704852a0fd57b8a64/XenModel/XenAPI/Session.cs#L403-L433
1010
export default ({ secureOptions, url, httpProxy }) => {
11+
let agent
12+
if (httpProxy !== undefined) {
13+
agent = new ProxyAgent(httpProxy)
14+
}
1115
return (method, args) =>
1216
httpRequestPlus
1317
.post(url, {
1418
...secureOptions,
15-
agent: httpProxy !== undefined ? new ProxyAgent(httpProxy) : undefined,
1619
body: format.request(0, method, args),
1720
headers: {
1821
Accept: 'application/json',
1922
'Content-Type': 'application/json',
2023
},
2124
path: '/jsonrpc',
25+
agent,
2226
})
2327
.readAll('utf8')
2428
.then(

packages/xen-api/src/transports/xml-rpc-json.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ const parseResult = result => {
7373

7474
export default ({ secureOptions, url: { hostname, port, protocol }, httpProxy }) => {
7575
const secure = protocol === 'https:'
76+
let agent
77+
if (httpProxy !== undefined) {
78+
agent = new ProxyAgent(httpProxy)
79+
}
7680
const client = (secure ? createSecureClient : createClient)({
7781
...(secure ? secureOptions : undefined),
78-
agent: httpProxy !== undefined ? new ProxyAgent(httpProxy) : undefined,
82+
agent,
7983
host: hostname,
8084
path: '/json',
8185
port,

packages/xen-api/src/transports/xml-rpc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ const parseResult = result => {
3333

3434
export default ({ secureOptions, url: { hostname, port, protocol, httpProxy } }) => {
3535
const secure = protocol === 'https:'
36-
36+
let agent
37+
if (httpProxy !== undefined) {
38+
agent = new ProxyAgent(httpProxy)
39+
}
3740
const client = (secure ? createSecureClient : createClient)({
3841
...(secure ? secureOptions : undefined),
39-
agent: httpProxy !== undefined ? new ProxyAgent(httpProxy) : undefined,
42+
agent,
4043
host: hostname,
4144
port,
4245
})

0 commit comments

Comments
 (0)