Skip to content

Commit

Permalink
Recompute proxyAgent on redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed Apr 21, 2022
1 parent 4c8abcd commit a4963f1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/vs/platform/request/node/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ export class RequestService extends Disposable implements IRequestService {
...process.env,
...shellEnv
};
const agent = options.agent ? options.agent : await getProxyAgent(options.url || '', env, { proxyUrl, strictSSL });

options.agent = agent;
options.strictSSL = strictSSL;

if (this.authorization) {
Expand All @@ -93,7 +91,7 @@ export class RequestService extends Disposable implements IRequestService {
}

try {
const res = await this._request(options, token);
const res = await this._request(options, proxyUrl, env, token);

this.logService.trace('RequestService#request (node) - success', options.url);

Expand All @@ -111,7 +109,7 @@ export class RequestService extends Disposable implements IRequestService {
return module.request;
}

private _request(options: NodeRequestOptions, token: CancellationToken): Promise<IRequestContext> {
private _request(options: NodeRequestOptions, proxyUrl: string | undefined, env: { [key: string]: string | undefined }, token: CancellationToken): Promise<IRequestContext> {

return Promises.withAsyncBody<IRequestContext>(async (c, e) => {
let req: http.ClientRequest;
Expand All @@ -121,14 +119,16 @@ export class RequestService extends Disposable implements IRequestService {
? options.getRawRequest(options)
: await this.getNodeRequest(options);

const proxyAgent = options.agent ? options.agent : await getProxyAgent(options.url || '', env, { proxyUrl, strictSSL: options.strictSSL });

const opts: https.RequestOptions = {
hostname: endpoint.hostname,
port: endpoint.port ? parseInt(endpoint.port) : (endpoint.protocol === 'https:' ? 443 : 80),
protocol: endpoint.protocol,
path: endpoint.path,
method: options.type || 'GET',
headers: options.headers,
agent: options.agent,
agent: proxyAgent,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
};

Expand All @@ -143,7 +143,7 @@ export class RequestService extends Disposable implements IRequestService {
...options,
url: res.headers['location'],
followRedirects: followRedirects - 1
}, token).then(c, e);
}, proxyUrl, env, token).then(c, e);
} else {
let stream: streams.ReadableStreamEvents<Uint8Array> = res;

Expand Down

0 comments on commit a4963f1

Please sign in to comment.