avancement planning
This commit is contained in:
+6
@@ -11,6 +11,7 @@ const util_1 = __importDefault(require("util"));
|
||||
const error_1 = require("./error");
|
||||
const tmpfile_1 = require("./utils/tmpfile");
|
||||
const log = (0, debug_1.default)('tuf:fetch');
|
||||
const USER_AGENT_HEADER = 'User-Agent';
|
||||
class BaseFetcher {
|
||||
// Download file from given URL. The file is downloaded to a temporary
|
||||
// location and then passed to the given handler. The handler is responsible
|
||||
@@ -54,16 +55,21 @@ class BaseFetcher {
|
||||
}
|
||||
exports.BaseFetcher = BaseFetcher;
|
||||
class DefaultFetcher extends BaseFetcher {
|
||||
userAgent;
|
||||
timeout;
|
||||
retry;
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
this.userAgent = options.userAgent;
|
||||
this.timeout = options.timeout;
|
||||
this.retry = options.retry;
|
||||
}
|
||||
async fetch(url) {
|
||||
log('GET %s', url);
|
||||
const response = await (0, make_fetch_happen_1.default)(url, {
|
||||
headers: {
|
||||
[USER_AGENT_HEADER]: this.userAgent || '',
|
||||
},
|
||||
timeout: this.timeout,
|
||||
retry: this.retry,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user