Skip to content

Commit df2bf8b

Browse files
committed
http.proxyAuthorization setting
fixes microsoft#6480
1 parent f7a6d19 commit df2bf8b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/vs/platform/request/common/request.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IHTTPConfiguration {
2323
http?: {
2424
proxy?: string;
2525
proxyStrictSSL?: boolean;
26+
proxyAuthorization?: string;
2627
};
2728
}
2829

@@ -42,6 +43,11 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration)
4243
type: 'boolean',
4344
default: true,
4445
description: localize('strictSSL', "Whether the proxy server certificate should be verified against the list of supplied CAs.")
46+
},
47+
'http.proxyAuthorization': {
48+
type: 'string',
49+
default: null,
50+
description: localize('proxyAuthorization', "The value to send as the 'Proxy-Authorization' header for every network request.")
4551
}
4652
}
4753
});

src/vs/platform/request/node/requestService.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { TPromise } from 'vs/base/common/winjs.base';
88
import { IDisposable } from 'vs/base/common/lifecycle';
9+
import { assign } from 'vs/base/common/objects';
910
import { IRequestOptions, IRequestContext, request } from 'vs/base/node/request';
1011
import { getProxyAgent } from 'vs/base/node/proxy';
1112
import { IRequestService, IHTTPConfiguration } from 'vs/platform/request/common/request';
@@ -21,6 +22,7 @@ export class RequestService implements IRequestService {
2122

2223
private proxyUrl: string;
2324
private strictSSL: boolean;
25+
private authorization: string;
2426
private disposables: IDisposable[] = [];
2527

2628
constructor(
@@ -37,6 +39,7 @@ export class RequestService implements IRequestService {
3739
private configure(config: IHTTPConfiguration) {
3840
this.proxyUrl = config.http && config.http.proxy;
3941
this.strictSSL = config.http && config.http.proxyStrictSSL;
42+
this.authorization = config.http && config.http.proxyAuthorization;
4043
}
4144

4245
request(options: IRequestOptions): TPromise<IRequestContext> {
@@ -45,6 +48,10 @@ export class RequestService implements IRequestService {
4548
options.agent = getProxyAgent(options.url, { proxyUrl, strictSSL });
4649
}
4750

51+
if (this.authorization) {
52+
options.headers = assign(options.headers || {}, { 'Proxy-Authorization': this.authorization });
53+
}
54+
4855
return request(options);
4956
}
5057
}

0 commit comments

Comments
 (0)