Core NodeJS
HTTP Module
The HTTP core module is a key module in Node used for networking.
import http from 'http'
You can also use frameworks build on top of it like express
and fastify
. These frameworks are built on top of Node's core HTTP module.
Classes
The HTTP module provides 5 classes:
- http.Agent: A global instance of the http.Agent class is created to
- Efficiently manage a connection's persistance
- Reuse a single socket connection for HTTP clients
- Maintain a pool of sockets
- Ensure every request to the server is queued
- http.ClientRequest: Node creates this object when we make a request using methods like http.request() or http.get(). The
http.ClientRequest
object creates ahttp.IncomingMessage
object when listening to theresponse
event. - http.Server
- http.ServerResponse
- http.IncomingMessage