Sobes.tech
Junior — Middle

Does the server response have a body?

sobes.tech AI

Answer from AI

Yes, the server's response usually includes a response body. The response body contains data that the server sends to the client, such as an HTML page, JSON data, a file, or plain text. However, the body may be absent if, for example, the server responds with a status code indicating no content (e.g., 204 No Content).

Example in Node.js using the built-in http module:

const http = require('http');

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello, world!'); // response body
});

server.listen(3000);