1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

Updated wget, to support options

This commit is contained in:
Bryan Roe
2019-03-04 23:54:58 -08:00
parent 268b0dd26f
commit 0ad37730c0
2 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -20,7 +20,7 @@ var http = require('http');
var writable = require('stream').Writable; var writable = require('stream').Writable;
function wget(remoteUri, localFilePath) function wget(remoteUri, localFilePath, wgetoptions)
{ {
var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; }); var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
var agentConnected = false; var agentConnected = false;
@@ -55,8 +55,15 @@ function wget(remoteUri, localFilePath)
} }
} }
var reqOptions = require('http').parseUri(remoteUri);
if (wgetoptions)
{
for (var inputOption in wgetoptions) {
reqOptions[inputOption] = wgetoptions[inputOption];
}
}
ret._totalBytes = 0; ret._totalBytes = 0;
ret._request = http.get(remoteUri); ret._request = http.get(reqOptions);
ret._localFilePath = localFilePath; ret._localFilePath = localFilePath;
ret._request.promise = ret; ret._request.promise = ret;
ret._request.on('error', function (e) { this.promise._rej(e); }); ret._request.on('error', function (e) { this.promise._rej(e); });