From c1bf41baffb56aff0adcf8f5054e50889707e5c0 Mon Sep 17 00:00:00 2001 From: Austin Willoughby Date: Wed, 11 Sep 2024 11:24:39 -0400 Subject: [PATCH] Added content-length --- src/htmlResponses.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/htmlResponses.js b/src/htmlResponses.js index 304f1a2..258084f 100644 --- a/src/htmlResponses.js +++ b/src/htmlResponses.js @@ -8,8 +8,11 @@ const index = fs.readFileSync(`${__dirname}/../client/client.html`); // function to handle the index page const getIndex = (request, response) => { - // set status code (200 success) and content type - response.writeHead(200, { 'Content-Type': 'text/html' }); + // set status code (200 success), content type, and content length + response.writeHead(200, { + 'Content-Type': 'text/html', + 'Content-Length': Buffer.byteLength(index, 'utf8'), + }); // write an HTML string or buffer to the response response.write(index); // send the response to the client.