https
An implementation of the Node.js `https.Agent' ↗ class.
An Agent ↗ manages HTTPS connection reuse by maintaining request queues per host/port. In the
workers environment, however, such low-level management of the network connection, ports,
etc, is not relevant because it is handled by the Cloudflare infrastructure instead. Accordingly, the
implementation of Agent
in Workers is a stub implementation that does not support connection
pooling or keep-alive.
import { Agent } from "node:https";import { strictEqual } from "node:assert";
const agent = new Agent();strictEqual(agent.protocol, "https:");
An implementation of the Node.js `https.get' ↗ method.
The get
↗ method performs a GET request to the specified URL and invokes the callback with the response. This is a convenience method that simplifies making HTTPS GET requests without manually configuring request options.
import { get } from "node:https";
export default { async fetch() { const { promise, resolve, reject } = Promise.withResolvers(); get("http://example.com", (res) => { let data = ""; res.setEncoding("utf8"); res.on("data", (chunk) => { data += chunk; }); res.on("error", reject); res.on("end", () => { resolve(new Response(data)); }); }).on("error", reject); return promise; },};
An implementation of the Node.js `https.request' ↗ method.
The request
↗ method creates an HTTPS request with customizable options like method, headers, and body. It provides full control over the request configuration and returns a writable stream ↗ for sending request data.
Request method accepts all options from http.request
with some differences in default values:
protocol
: defaulthttps:
port
: default443
agent
: defaulthttps.globalAgent
import { request } from "node:https";import { strictEqual, ok } from "node:assert";
const req = request( "https://developers.cloudflare.com/robots.txt", { method: "GET", }, (res) => { strictEqual(res.statusCode, 200); let data = ""; res.setEncoding("utf8"); res.on("data", (chunk) => { data += chunk; }); res.on("end", () => { ok(data.includes("User-agent")); }); },);req.end();
The following additional options are not supported: ca
, cert
, ciphers
, clientCertEngine
(deprecated), crl
, dhparam
, ecdhCurve
, honorCipherOrder
, key
, passphrase
, pfx
, rejectUnauthorized
, secureOptions
, secureProtocol
, servername
, sessionIdContext
, highWaterMark
.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark