Commit b4f82d80 by xzyfer Committed by Michael Mifsud

Fix wrong binary encoding

Due to #1912 we were writing binaries to disk with the encoding.
We need to do some additional juggling when dealing with binary
data.
parent 0b6baf38
......@@ -51,7 +51,7 @@ function download(url, dest, cb) {
console.log('Downloading binary from', url);
try {
request(url, downloadOptions(), function(err, response) {
request(url, downloadOptions(), function(err, response, buffer) {
if (err) {
reportError(err);
} else if (!successful(response)) {
......@@ -60,11 +60,13 @@ function download(url, dest, cb) {
console.log('Download complete');
if (successful(response)) {
response.pipe(fs.createWriteStream(dest));
}
fs.createWriteStream(dest)
.on('error', cb)
.end(buffer, cb);
} else {
cb();
}
}
})
.on('response', function(response) {
var length = parseInt(response.headers['content-length'], 10);
......
......@@ -18,7 +18,8 @@ module.exports = function() {
timeout: 60000,
headers: {
'User-Agent': userAgent(),
}
},
encoding: null,
};
var proxyConfig = proxy();
......
......@@ -12,7 +12,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};
assert.deepEqual(opts(), expected);
......@@ -37,7 +38,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};
assert.deepEqual(opts(), expected);
......@@ -61,7 +63,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};
assert.deepEqual(opts(), expected);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment