Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
32 lines (32 sloc) 1.18 KB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpManager = void 0;
const utils_1 = require("./utils");
/**
* Used for managing http clients during either upload or download
*/
class HttpManager {
constructor(clientCount, userAgent) {
if (clientCount < 1) {
throw new Error('There must be at least one client');
}
this.userAgent = userAgent;
this.clients = new Array(clientCount).fill(utils_1.createHttpClient(userAgent));
}
getClient(index) {
return this.clients[index];
}
// client disposal is necessary if a keep-alive connection is used to properly close the connection
// for more information see: https://github.com/actions/http-client/blob/04e5ad73cd3fd1f5610a32116b0759eddf6570d2/index.ts#L292
disposeAndReplaceClient(index) {
this.clients[index].dispose();
this.clients[index] = utils_1.createHttpClient(this.userAgent);
}
disposeAndReplaceAllClients() {
for (const [index] of this.clients.entries()) {
this.disposeAndReplaceClient(index);
}
}
}
exports.HttpManager = HttpManager;
//# sourceMappingURL=http-manager.js.map