@@ -194,11 +194,17 @@ export function findLocalToolVersions(toolName: string, arch?: string) {
194
194
/**
195
195
* Download a tool from an url and stream it into a file
196
196
*
197
- * @param url url of tool to download
198
- * @param fileName optional fileName. Should typically not use (will be a guid for reliability). Can pass fileName with an absolute path.
199
- * @param handlers optional handlers array. Auth handlers to pass to the HttpClient for the tool download.
197
+ * @param url url of tool to download
198
+ * @param fileName optional fileName. Should typically not use (will be a guid for reliability). Can pass fileName with an absolute path.
199
+ * @param handlers optional handlers array. Auth handlers to pass to the HttpClient for the tool download.
200
+ * @param additionalHeaders optional custom HTTP headers. This is passed to the REST client that downloads the tool.
200
201
*/
201
- export async function downloadTool ( url : string , fileName ?: string , handlers ?: ifm . IRequestHandler [ ] ) : Promise < string > {
202
+ export async function downloadTool (
203
+ url : string ,
204
+ fileName ?: string ,
205
+ handlers ?: ifm . IRequestHandler [ ] ,
206
+ additionalHeaders ?: ifm . IHeaders
207
+ ) : Promise < string > {
202
208
return new Promise < string > ( async ( resolve , reject ) => {
203
209
try {
204
210
handlers = handlers || null ;
@@ -226,9 +232,9 @@ export async function downloadTool(url: string, fileName?: string, handlers?: if
226
232
if ( fs . existsSync ( destPath ) ) {
227
233
throw new Error ( "Destination file path already exists" ) ;
228
234
}
229
-
235
+
230
236
tl . debug ( 'downloading' ) ;
231
- let response : httpm . HttpClientResponse = await http . get ( url ) ;
237
+ let response : httpm . HttpClientResponse = await http . get ( url , additionalHeaders ) ;
232
238
233
239
if ( response . message . statusCode != 200 ) {
234
240
let err : Error = new Error ( 'Unexpected HTTP response: ' + response . message . statusCode ) ;
0 commit comments