🔥 Remove debug output from file download
This commit is contained in:
parent
c051139c0f
commit
561a40be63
1 changed files with 7 additions and 5 deletions
|
@ -13,25 +13,27 @@ export const getFileContents: () => Promise<Buffer> = () => new Promise((resolve
|
|||
host: 'cdn-patch.swtor.com',
|
||||
path,
|
||||
}, (response) => {
|
||||
console.log(`STATUS: ${response.statusCode}`);
|
||||
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
||||
if (response.statusCode !== 200) {
|
||||
return reject(`Expected status code 200 but received ${response.statusCode}`);
|
||||
}
|
||||
const headerLength = Number(response.headers['content-length']);
|
||||
|
||||
const chunkList: Buffer[] = [];
|
||||
let totalLength = 0;
|
||||
response.on('data', (chunk: Buffer) => {
|
||||
console.log(`BODY: ${chunk.length}`);
|
||||
chunkList.push(chunk);
|
||||
totalLength += chunk.length;
|
||||
});
|
||||
response.on('end', () => {
|
||||
console.log('No more data in response.');
|
||||
if (totalLength !== headerLength) {
|
||||
return reject(`Expected length ${headerLength} but received ${totalLength}`);
|
||||
}
|
||||
const fileContents = Buffer.concat(chunkList, totalLength);
|
||||
resolve(fileContents);
|
||||
});
|
||||
});
|
||||
|
||||
request.on('error', (e) => {
|
||||
console.error(`problem with request: ${e.message}`);
|
||||
reject(e);
|
||||
});
|
||||
request.end();
|
||||
|
|
Loading…
Reference in a new issue