Update https.js

This commit is contained in:
Jasper 2022-09-09 23:30:19 +10:00
parent 3b9ad9b75b
commit ea1f96c8ec
1 changed files with 5 additions and 2 deletions

View File

@ -4,16 +4,19 @@ import Remote from "./remote";
export function get(url, options = {}, callback) {
if (typeof(options) === "function") {
callback = options;
options = null;
options = {};
}
const emitter = new EventEmitter();
callback(emitter);
if(!options.encoding)
options['encoding'] = "binary";
Remote.https.get(url, options, (error, res, body) => {
if (error) return emitter.emit("error", error);
emitter.emit("data", body);
emitter.emit("data", new Buffer(Buffer.from(body,"binary")));
emitter.emit("end", res);
});