You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers/runtime-apis/nodejs/http.mdx
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@ import { Render } from "~/components"
9
9
10
10
## Agent
11
11
12
-
An Agent manages HTTP connection reuse by maintaining request queues per host/port. In the
12
+
An implementation of the Node.js [`http.Agent'](https://nodejs.org/docs/latest/api/http.html#class-httpagent) class.
13
+
14
+
An [Agent](https://nodejs.org/docs/latest/api/http.html#class-httpagent) manages HTTP connection reuse by maintaining request queues per host/port. In the
13
15
workers environment, however, such low-level management of the network connection, ports,
14
16
etc, is not relevant because it is handled by the Cloudflare infrastructure instead. Accordingly, the
15
17
implementation of `Agent` in Workers is a stub implementation that does not support connection
An implementation of the Node.js [`http.request'](https://nodejs.org/docs/latest/api/http.html#httprequesturl-options-callback) method.
55
+
54
56
The `request` method creates an HTTP request with customizable options like method, headers, and body. It provides full control over the request configuration and returns a [writable stream](https://nodejs.org/docs/latest/api/stream.html#class-streamwritable) for sending request data.
55
57
56
58
```js
@@ -63,7 +65,7 @@ const req = request({
63
65
hostname:'docs.cloudflare.com',
64
66
path:'/'
65
67
}, (res) => {
66
-
// http://docs.cloudflare.com redirects to https url.
68
+
//requests to http://docs.cloudflare.com get redirected to their https counterpart.
// http://docs.cloudflare.com redirects to https url.
87
+
//requests to http://docs.cloudflare.com get redirected to their https counterpart.
86
88
strictEqual(res.statusCode, 301);
87
89
});
88
90
89
-
req2.end();
91
+
req.end();
90
92
```
91
93
92
94
The following options passed to the `request` method are not supported due to the differences in the Cloudflare Workers and the implementation of the `node:http` module:
Copy file name to clipboardExpand all lines: src/content/docs/workers/runtime-apis/nodejs/https.mdx
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@ import { Render } from "~/components"
9
9
10
10
## Agent
11
11
12
-
An Agent manages HTTPS connection reuse by maintaining request queues per host/port. In the
12
+
An implementation of the Node.js [`https.Agent'](https://nodejs.org/docs/latest/api/https.html#class-httpsagent) class.
13
+
14
+
An [Agent](https://nodejs.org/docs/latest/api/https.html#class-httpsagent) manages HTTPS connection reuse by maintaining request queues per host/port. In the
13
15
workers environment, however, such low-level management of the network connection, ports,
14
16
etc, is not relevant because it is handled by the Cloudflare infrastructure instead. Accordingly, the
15
17
implementation of `Agent` in Workers is a stub implementation that does not support connection
The [`get`](https://nodejs.org/docs/latest/api/https.html#httpsgetoptions-callback) 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.
30
+
An implementation of the Node.js [`https.get'](https://nodejs.org/docs/latest/api/https.html#httpsgetoptions-callback) method.
29
31
30
-
`get` methods behaves the same as `node:http` get method.
32
+
The [`get`](https://nodejs.org/docs/latest/api/https.html#httpsgetoptions-callback) 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.
The [`request`](https://nodejs.org/docs/latest/api/https.html#httpsrequesturl-options-callback) 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](https://nodejs.org/docs/latest/api/stream.html#class-streamwritable) for sending request data.
53
+
An implementation of the Node.js [`https.request'](https://nodejs.org/docs/latest/api/https.html#httpsrequestoptions-callback) method.
54
+
55
+
The [`request`](https://nodejs.org/docs/latest/api/https.html#httpsrequestoptions-callback) 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](https://developers.cloudflare.com/workers/runtime-apis/streams/writablestream/) for sending request data.
54
56
55
57
Request method accepts all options from `http.request` with some differences in default values:
56
58
-`protocol`: default `https:`
57
59
-`port`: default `443`
58
60
-`agent`: default `https.globalAgent`
59
61
60
-
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`.
0 commit comments