Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createRequestOptions(): RequestOptions {
const result = {
headers: {
...this.options.requestHeaders,
accept: "*/*",
},
}
configureRequestUrl(this.options.newUrl, result)
// user-agent, cache-control and other common options
configureRequestOptions(result)
return result
}
request.on("redirect", (statusCode: number, method: string, redirectUrl: string) => {
this.logger.info(`Redirect to ${removeQuery(redirectUrl)}`)
actualUrl = redirectUrl
configureRequestUrl(new URL(actualUrl), requestOptions)
request.followRedirect()
})
this.httpExecutor.addErrorAndTimeoutHandlers(request, reject)
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
const requestOptions = {
headers: options.headers || undefined,
redirect: "manual",
}
configureRequestUrl(url, requestOptions)
configureRequestOptions(requestOptions)
this.doDownload(requestOptions, {
destination,
options,
onCancel,
callback: error => {
if (error == null) {
resolve(destination)
}
else {
reject(error)
}
},
responseHandler: null,
}, 0)
})