Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2022-04-20 11:23:41 +0300
committerMichaƫl Zasso <targos@protonmail.com>2022-04-28 07:56:14 +0300
commit3d65a3b13e61f136dc09027aa12473c2b3003725 (patch)
tree012259a22a22fec5325afd386bbae62e3293a09f /doc/api/http.md
parent46c880b99b4a74c3a7c99fdd824bf9ce22333987 (diff)
doc: add `node:` prefix for all core modules
Some core modules can be loaded with or without the `node:` prefix. Using the prefix disambiguates which specifiers refer to core modules. This commit updates the docs to use the prefix everywhere a core module is referenced. PR-URL: https://github.com/nodejs/node/pull/42752 Fixes: https://github.com/nodejs/node/issues/38343 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'doc/api/http.md')
-rw-r--r--doc/api/http.md36
1 files changed, 18 insertions, 18 deletions
diff --git a/doc/api/http.md b/doc/api/http.md
index c98eac6e024..543a25dfdf8 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -6,7 +6,7 @@
<!-- source_link=lib/http.js -->
-To use the HTTP server and client one must `require('http')`.
+To use the HTTP server and client one must `require('node:http')`.
The HTTP interfaces in Node.js are designed to support many features
of the protocol which have been traditionally difficult to use.
@@ -188,7 +188,7 @@ of these values set to their respective defaults.
To configure any of them, a custom [`http.Agent`][] instance must be created.
```js
-const http = require('http');
+const http = require('node:http');
const keepAliveAgent = new http.Agent({ keepAlive: true });
options.agent = keepAliveAgent;
http.request(options, onResponseCallback);
@@ -468,9 +468,9 @@ type other than {net.Socket}.
A client and server pair demonstrating how to listen for the `'connect'` event:
```js
-const http = require('http');
-const net = require('net');
-const { URL } = require('url');
+const http = require('node:http');
+const net = require('node:net');
+const { URL } = require('node:url');
// Create an HTTP tunneling proxy
const proxy = http.createServer((req, res) => {
@@ -564,7 +564,7 @@ HTTP version, status code, status message, key-value headers object,
and array with the raw header names followed by their respective values.
```js
-const http = require('http');
+const http = require('node:http');
const options = {
host: '127.0.0.1',
@@ -642,7 +642,7 @@ type other than {net.Socket}.
A client server pair demonstrating how to listen for the `'upgrade'` event.
```js
-const http = require('http');
+const http = require('node:http');
// Create an HTTP server
const server = http.createServer((req, res) => {
@@ -1010,7 +1010,7 @@ might be reused. But if server closes connection at unfortunate time, client
may run into a 'ECONNRESET' error.
```js
-const http = require('http');
+const http = require('node:http');
// Server has a 5 seconds keep-alive timeout by default
http
@@ -1034,7 +1034,7 @@ By marking a request whether it reused socket or not, we can do
automatic error retry base on it.
```js
-const http = require('http');
+const http = require('node:http');
const agent = new http.Agent({ keepAlive: true });
function retriableRequest() {
@@ -1144,7 +1144,7 @@ this property. In particular, the socket will not emit `'readable'` events
because of how the protocol parser attaches to the socket.
```js
-const http = require('http');
+const http = require('node:http');
const options = {
host: 'www.google.com',
};
@@ -1311,7 +1311,7 @@ written data it is immediately destroyed.
`socket` is the [`net.Socket`][] object that the error originated from.
```js
-const http = require('http');
+const http = require('node:http');
const server = http.createServer((req, res) => {
res.end();
@@ -1957,7 +1957,7 @@ because of how the protocol parser attaches to the socket. After
`response.end()`, the property is nulled.
```js
-const http = require('http');
+const http = require('node:http');
const server = http.createServer((req, res) => {
const ip = res.socket.remoteAddress;
const port = res.socket.remotePort;
@@ -2058,7 +2058,7 @@ it will switch to implicit header mode and flush the implicit headers.
This sends a chunk of the response body. This method may
be called multiple times to provide successive parts of the body.
-In the `http` module, the response body is omitted when the
+In the `node:http` module, the response body is omitted when the
request is a HEAD request. Similarly, the `204` and `304` responses
_must not_ include a message body.
@@ -3020,7 +3020,7 @@ The `requestListener` is a function which is automatically
added to the [`'request'`][] event.
```cjs
-const http = require('http');
+const http = require('node:http');
// Create a local server to receive data from
const server = http.createServer((req, res) => {
@@ -3034,7 +3034,7 @@ server.listen(8000);
```
```cjs
-const http = require('http');
+const http = require('node:http');
// Create a local server to receive data from
const server = http.createServer();
@@ -3272,7 +3272,7 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
upload a file with a POST request, then write to the `ClientRequest` object.
```js
-const http = require('http');
+const http = require('node:http');
const postData = JSON.stringify({
'msg': 'Hello World!'
@@ -3471,7 +3471,7 @@ Examples:
Example:
```js
-const { validateHeaderName } = require('http');
+const { validateHeaderName } = require('node:http');
try {
validateHeaderName('');
@@ -3505,7 +3505,7 @@ or response. The HTTP module will automatically validate such headers.
Examples:
```js
-const { validateHeaderValue } = require('http');
+const { validateHeaderValue } = require('node:http');
try {
validateHeaderValue('x-my-header', undefined);