ServerResponse
The Node.js object a server uses to answer one HTTP request: a Writable stream with methods for setting the status and headers.
In more detail
Headers go out with the first write or writeHead(), after which they cannot change. end() finishes the response.
Related terms
- node:http — The built-in Node.js module for writing HTTP/1.1 servers and clients, which web frameworks such as Express and Fastify build on.
- Writable stream — A Node.js stream you write data to, such as a file being written, an HTTP response or a socket.
- writeHead() — The ServerResponse method that sends the status code and headers of an HTTP response in one go.
Taught in
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services