@@ -11,6 +11,7 @@ import * as path from "path";
11
11
import { log , assert } from "./util" ;
12
12
import * as url from "url" ;
13
13
import * as https from "https" ;
14
+ import { ProxySettings } from "./config" ;
14
15
15
16
const pipeline = util . promisify ( stream . pipeline ) ;
16
17
@@ -29,8 +30,7 @@ function makeHttpAgent(proxy: string | null | undefined, options?: https.AgentOp
29
30
export async function fetchRelease (
30
31
releaseTag : string ,
31
32
githubToken : string | null | undefined ,
32
- httpProxy : string | null | undefined ,
33
- proxyStrictSSL : boolean ,
33
+ proxySettings : ProxySettings ,
34
34
) : Promise < GithubRelease > {
35
35
36
36
const apiEndpointPath = `/repos/${ OWNER } /${ REPO } /releases/tags/${ releaseTag } ` ;
@@ -45,14 +45,14 @@ export async function fetchRelease(
45
45
}
46
46
47
47
const response = await ( ( ) => {
48
- if ( httpProxy ) {
49
- log . debug ( `Fetching release metadata via proxy: ${ httpProxy } ` ) ;
48
+ if ( proxySettings . proxy ) {
49
+ log . debug ( `Fetching release metadata via proxy: ${ proxySettings . proxy } ` ) ;
50
50
}
51
- let options : any = { } ;
52
- if ( proxyStrictSSL ) {
51
+ const options : any = { } ;
52
+ if ( proxySettings . strictSSL ) {
53
53
options [ "rejectUnauthorized" ] = false ;
54
54
}
55
- const agent = makeHttpAgent ( httpProxy , options ) ;
55
+ const agent = makeHttpAgent ( proxySettings . proxy , options ) ;
56
56
return fetch ( requestUrl , { headers : headers , agent : agent } ) ;
57
57
} ) ( ) ;
58
58
@@ -97,8 +97,7 @@ interface DownloadOpts {
97
97
dest : vscode . Uri ;
98
98
mode ?: number ;
99
99
gunzip ?: boolean ;
100
- httpProxy ?: string ;
101
- proxyStrictSSL : boolean ;
100
+ proxySettings : ProxySettings ;
102
101
}
103
102
104
103
export async function download ( opts : DownloadOpts ) {
@@ -118,7 +117,7 @@ export async function download(opts: DownloadOpts) {
118
117
} ,
119
118
async ( progress , _cancellationToken ) => {
120
119
let lastPercentage = 0 ;
121
- await downloadFile ( opts . url , tempFilePath , opts . mode , ! ! opts . gunzip , opts . httpProxy , opts . proxyStrictSSL , ( readBytes , totalBytes ) => {
120
+ await downloadFile ( opts . url , tempFilePath , opts . mode , ! ! opts . gunzip , opts . proxySettings , ( readBytes , totalBytes ) => {
122
121
const newPercentage = Math . round ( ( readBytes / totalBytes ) * 100 ) ;
123
122
if ( newPercentage !== lastPercentage ) {
124
123
progress . report ( {
@@ -182,21 +181,20 @@ async function downloadFile(
182
181
destFilePath : vscode . Uri ,
183
182
mode : number | undefined ,
184
183
gunzip : boolean ,
185
- httpProxy : string | null | undefined ,
186
- proxyStrictSSL : boolean ,
184
+ proxySettings : ProxySettings ,
187
185
onProgress : ( readBytes : number , totalBytes : number ) => void
188
186
) : Promise < void > {
189
187
const urlString = url . toString ( ) ;
190
188
191
189
const res = await ( ( ) => {
192
- if ( httpProxy ) {
193
- log . debug ( `Downloading ${ urlString } via proxy: ${ httpProxy } ` ) ;
190
+ if ( proxySettings . proxy ) {
191
+ log . debug ( `Downloading ${ urlString } via proxy: ${ proxySettings . proxy } ` ) ;
194
192
}
195
- let options : any = { } ;
196
- if ( proxyStrictSSL ) {
193
+ const options : any = { } ;
194
+ if ( proxySettings . strictSSL ) {
197
195
options [ "rejectUnauthorized" ] = false ;
198
196
}
199
- const agent = makeHttpAgent ( httpProxy , options ) ;
197
+ const agent = makeHttpAgent ( proxySettings . proxy , options ) ;
200
198
return fetch ( urlString , { agent : agent } ) ;
201
199
} ) ( ) ;
202
200
0 commit comments