Node.js module
http
The 'node:http' module provides classes and methods to create HTTP servers and clients. It includes the IncomingMessage and ServerResponse classes for handling request/response lifecycles on the server side, and the ClientRequest and IncomingMessage classes for client-side HTTP interactions.
Fully supported in Bun
Fully implemented. Note: Outgoing client request body is currently buffered instead of streamed.
Functions 7
- http.createServer()
Returns a new instance of Server.
- http.get()
Since most requests are GET requests without bodies, Node.js provides this convenience method.
- http.request()
optionsinsocket.connect()are also supported. - http.setGlobalProxyFromEnv()
Dynamically resets the global configurations to enable built-in proxy support for
- http.setMaxIdleHTTPParsers()
Set the maximum number of idle HTTP parsers.
- http.validateHeaderName()
Performs the low-level validations on the provided
namethat are done whenres.setHeader(name, value)is called. - http.validateHeaderValue()
Performs the low-level validations on the provided
valuethat are done whenres.setHeader(name, value)is called.
Classes 6
- class http.Agent
An
Agentis responsible for managing connection persistence and reuse for HTTP clients. - class http.ClientRequest
This object is created internally and returned from request.
- class http.IncomingMessage
An
IncomingMessageobject is created by Server or ClientRequest and passed as the first argument to the'request'and'response'event respectively. - class http.OutgoingMessage
This class serves as the parent class of ClientRequest and ServerResponse.
- class http.Server
- class http.ServerResponse
This object is created internally by an HTTP server, not by the user.
Interfaces 12
- interface AgentOptions
- interface ClientRequestArgs
- interface ClientRequestEventMap
- interface IncomingHttpHeaders
- interface IncomingMessageEventMap
- interface InformationEvent
- interface OutgoingHttpHeaders
- interface OutgoingMessageEventMap
- interface ProxyEnv
- interface RequestOptions
- interface ServerEventMap
- interface ServerOptions
Types 2
Variables 7
- const http.CloseEvent
- const http.globalAgent
Global instance of
Agentwhich is used as the default for all HTTP client requests. - const http.maxHeaderSize
Read-only property specifying the maximum allowed size of HTTP headers in bytes.
- const http.MessageEvent
- const http.METHODS
- const http.STATUS_CODES
- const http.WebSocket
A browser-compatible implementation of
WebSocket.