node:http

HTTP/1.1 server and client, and the HTTPS client.

node:http provides the Node HTTP/1.1 server and client; node:https provides the client only. For a Fetch-style handler or HTTP/2, use Elide.serve.

Exports

Agent, ClientRequest, IncomingMessage, OutgoingMessage, Server, ServerResponse, createServer, request, get, globalAgent, METHODS, STATUS_CODES, maxHeaderSize (16384), validateHeaderName, validateHeaderValue, and setMaxIdleHTTPParsers. node:https has its own Agent and globalAgent.

Differences from Node

  • https.createServer throws ERR_HTTPS_SERVER_UNSUPPORTED; terminate TLS in front of http.createServer.
  • http.globalAgent defaults to keepAlive: true, maxSockets: Infinity, and maxFreeSockets: 256.
  • HTTPS certificate validation follows fetch.
  • node:http2 is unavailable.
  • --allow-net and --deny-net apply under the sandbox.