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.
In more detail
createServer((req, res) => ...) calls your handler with an IncomingMessage and a ServerResponse for every request. Both are streams, so bodies can be streamed rather than held in memory.
Related terms
- IncomingMessage — The Node.js object for an HTTP request a server has received, or a response a client has received, which is a Readable stream of the body.
- ServerResponse — The Node.js object a server uses to answer one HTTP request: a Writable stream with methods for setting the status and headers.
- HTTP — The protocol web browsers and web servers use to send requests and responses.
- web framework — A library that provides the structure for building web applications, such as routing, middleware and request parsing, so you do not write them yourself.
Taught in
- Poll & Check Phases: I/O Callbacks & setImmediate — Node.js Internals & Backend Services
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services
- Routing & Middleware: Path Parsing & Async Context — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services