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
}
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)
})
}
"X-Bintray-Publish": "1",
"X-Bintray-Debian-Architecture": toLinuxArchString(arch, "deb")
}
}
if (this.client.distribution != null) {
options.headers!!["X-Bintray-Debian-Distribution"] = this.client.distribution
}
if (this.client.component != null) {
options.headers!!["X-Bintray-Debian-Component"] = this.client.component
}
for (let attemptNumber = 0; ; attemptNumber++) {
try {
return await httpExecutor.doApiRequest(configureRequestOptions(options, this.client.auth), this.context.cancellationToken, requestProcessor)
}
catch (e) {
if (attemptNumber < 3 && ((e instanceof HttpError && e.statusCode === 502) || e.code === "EPIPE")) {
continue
}
throw e
}
}
}
private doUploadFile(attemptNumber: number, parsedUrl: UrlWithStringQuery, fileName: string, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, release: any): Promise {
return httpExecutor.doApiRequest(configureRequestOptions({
hostname: parsedUrl.hostname,
path: parsedUrl.path,
method: "POST",
headers: {
accept: "application/vnd.github.v3+json",
"Content-Type": mime.getType(fileName) || "application/octet-stream",
"Content-Length": dataLength
}
}, this.token), this.context.cancellationToken, requestProcessor)
.catch(e => {
if ((e as any).statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
return this.overwriteArtifact(fileName, release)
.then(() => this.doUploadFile(attemptNumber, parsedUrl, fileName, dataLength, requestProcessor, release))
}
if (attemptNumber > 3) {