Skip to content

Commit

Permalink
Added content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWilloughby committed Sep 11, 2024
1 parent a9c3c7b commit c1bf41b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/htmlResponses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c1bf41b

Please sign in to comment.