Remove Zefie's chunking and async stuff. Will revisit later. Fixing alg first.

This commit is contained in:
Eric MacDonald
2021-08-07 15:11:18 -04:00
parent 6a286d6851
commit 7a69d3e8da
2 changed files with 19 additions and 47 deletions

View File

@@ -484,23 +484,15 @@ async function sendToClient(socket, headers_obj, data, compress_data = false) {
}
// compress if needed
if (compress_data && clen > 0 && !headers_obj['minisrv-already-compressed']) {
if (zdebug) console.log(" # Uncompressed data length:", clen);
if (compress_data && clen > 0) {
headers_obj["wtv-lzpf"] = 0;
var wtvcomp = new WTVLzpf();
var compressed_data = new Buffer.alloc(clen);
wtvcomp.on('data', (data, length, offset, complete) => {
data.copy(compressed_data, offset, 0, length);
if (complete !== false) {
data = new Buffer.alloc(complete);
compressed_data.copy(data, 0, 0, compressed_data.byteLength);
compressed_data, wtvcomp = null;
headers_obj['minisrv-already-compressed'] = true;
sendToClient(socket, headers_obj, data);
}
});
wtvcomp.Compress(data);
return;
data = wtvcomp.Compress(data);
console.log("data", data)
wtvcomp = null; // Makes the garbage gods happy so it cleans up our mess
}
if (headers_obj['minisrv-already-compressed']) delete headers_obj['minisrv-already-compressed'];